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

Eric Carter
Eric Carter
2,130 Points

What is the challenge task asking for?

I did what the prompt asked for but it doesn't seem to be registering with what the task is asking for?

shopping_list.rb
def create_shopping_list
  print "What is the list's name?"
  name = gets.chomp

  hash = {"name" => name, "items" => Array.new }
  return hash
end

2 Answers

Manish Giri
Manish Giri
16,266 Points

The challenge linked in your question is this -

Create a method named "create_shopping_list" that returns a hash. It does not need to ask for a name or get anything from standard input.

For that you just need to return a new Hash from the method -

def create_shopping_list
  Hash.new
end
Eric Carter
Eric Carter
2,130 Points

Ahhhh okay okay thanks a lot!

Ari Misha
Ari Misha
19,323 Points

Hiya there! The challenge just wants you to create a method called create_shopping_list and it doesnt need to return anything other than an empty hash. Its pretty straightforward , but i'll still attach the code with my answer.

def create_shopping_list
  {}
end

~ Ari

Eric Carter
Eric Carter
2,130 Points

Ohhhh okay it went right over my head! Thanks a lot.