Ruby Ruby Collections Build a Grocery List Program Create a Method That Returns an Array

Create a method called add_list_items that returns an array. It does not need to read from standard input.

Create a method called add_list_items that returns an array. It does not need to read from standard input.

array_method.rb

3 Answers

def add_list_items() hash = { "item" => Array.new }

return hash end puts add_list_item().inspect

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 57,564 Points

HI there,

Strange challenge, this one!

I got through it with:

def add_list_items
  return []
end

I hope that helps !

Steve.

Steve Hunter
Steve Hunter
Treehouse Moderator 57,564 Points

That just returns an unnamed empty array. Quite possibly the most useless function ever - and badly named too!

Jeff Delacruz
Jeff Delacruz
2,043 Points

This question needs to be re-written.