Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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