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 Create a Method That Returns a Hash

Sharon Eller
Sharon Eller
3,090 Points

Create a method named "create_shopping_list" that returns a hash

I'm pretty sure this code is correct. Can someone please tell me what I'm doing wrong?

shopping_list.rb
def create_shopping_list
  hash = {"name" => name }
  return hash
end

2 Answers

The value of name is looking for a variable called name. You'll need to have the value side of the arrow be a String literal with your name in it for instance.

def create_shopping_list
  hash = {"name" => "Sharon" }
  return hash
end
Sharon Eller
Sharon Eller
3,090 Points

Thanks, Geoff! Its always the obvious that stumps me.