Ruby Ruby Collections Build a Grocery List Program Method Returns with Hashes and Arrays

Modifying method to return a hash

The only error I am getting is 'Try again'. I can't think where to start to correct it.

shopping_list.rb
def create_shopping_list
  list = { title => "Grocery List", items => Array.new }
  return list
end

1 Answer

Steven Ang
Steven Ang
40,657 Points

Surround your keys with quotes

def create_shopping_list
  { "title" => "Grocery List", "items" => Array.new }
end

Thank you.