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 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.