Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNick Evershed
6,429 PointsDifferent output
def create_list print "What is the list name? " name = gets.chomp
hash = { "name" => name, "items" => Array.new }
return hash
end
def add_list_item print "What is the item called? " item_name = gets.chomp
hash = { "name" => item_name } return hash end
list = create_list() puts list.inspect
add_list_item().inspect
I have copied what he did in the video exactly, but for some reason whenever I type the item the program ends and dosen't display name ==> "(What I typed)"
3 Answers
KRIS NIKOLAISEN
54,972 PointsIf you check the video @ 18 seconds he enters
puts add_list_item().inspect
you just have
add_list_item().inspect
Jeff Muday
Treehouse Moderator 28,722 PointsThat's a very simple fix, drop in a "puts" in front of the last add_list_item().inspect and you will have it.
Ruby is a super cool language, enjoy!
def create_list
print "What is the list name? "
name = gets.chomp
hash = { "name" => name, "items" => Array.new }
return hash
end
def add_list_item
print "What is the item called? "
item_name = gets.chomp
hash = { "name" => item_name }
return hash
end
list = create_list()
puts list.inspect
puts add_list_item().inspect # you needed a puts here
Nick Evershed
6,429 PointsYea Ruby seems like the perfect language for me, anyways thanks guys :)
Jeff Muday
Treehouse Moderator 28,722 PointsJeff Muday
Treehouse Moderator 28,722 PointsKris, you beat me to another answer! You are the fastest gun in the west!