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 trial

Ruby

Asking me the same question twice, and I cant see why?

Im following along with a video on workspaces, I thought i had followed along as shown, but when I run it, it asks me for the list name. then shows my answer in a hash, then asks for an item name and then a quantity.

this is where it goes wrong, it should show me a hash of something like {"name" => "groceries", "items" =>["milk", "quantity" => 1"]}

like it does on the video, but my code asks for the item and then the quantity again and then shows a hash with only the item milk and the quantity 1?

I don't mind that it is wrong, but i cant see where Ive gone wrong. its probably something minor (like most of my errors in ruby!!) any help would be appreciated.

def create_list print "What is the name of the list? " 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

print "How much? " quantity = gets.chomp.to_i

hash = {"name" => item_name, "quantity" => quantity} return hash end

list = create_list() puts list.inspect list['items'].push(add_list_item())

puts add_list_item().inspect