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 Ruby Collections Build a Grocery List Program Build a Grocery List Program: Part 1

Michael Pastran
Michael Pastran
4,727 Points

add_list_item method help!!

hi i am a little confused in this part.

def add_list_item
  print "What are the items?: "
  item_name = gets.chomp

  hash = { "name" => name }
  return hash
end  

i was wondering why we create a hash with the key "name" and then the value of name. i thought we assigned name to the first hash we created in this program. i thought the code was going to look like this

def add_list_item
  print "What are the items?: "
  item_name = gets.chomp

  hash = { "item" => item_name }
  return hash
end  

thank you for any explanation.

It's a bug that causes an error and is corrected in the next video.

Michael Pastran
Michael Pastran
4,727 Points

ohhh okay, yeah i saw in the final code that it was fixed. i was really confused with that. lol thanks