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.

sometimes what goes on in the videos isn't parallel with the task!

Yeah at times it confusing between what is being asked, which tends to be vague, compared to the tasks performed in the video.

6 Answers

William Li
PRO
William Li
Pro Student 26,812 Points

Really? But Danny, this challenge is actually quite simple, you only need to define a method named add_list_items, and it returns an Array, any Array will do, including empty Array.

def add_list_items
  []
end

wow...thats what i put but what i put was [} and couldn't understand what I was doing wrong. thanks

i have a question for you. what importance does making a grocery list have when creating a social media platform? i feel like im wasting time even though this is a prerequisite to what i really need

William Li
William Li
Pro Student 26,812 Points

there's none, grocery_list is used as vehicle to teach Student various Ruby language constructs, Collection in this case. If you find this material too basic for you, you should skim/fastforward through the video, and just finish the quiz/challenge, then you can complete this course pretty quickly. Or you can just switch to another Ruby course at anytime.

I knew it. I'm trying to get to the part where they begin creating "Treebook" so I'm following along. What do you do on your spare time with all this coding knowledge? are you trying to create something from a CEO point of view or are you doing work for someone else? just curious

and if i skip through the videos will i still get the points and say its completed or does it have to play from beginning to the end

William Li
William Li
Pro Student 26,812 Points

You don't even need to watch the videos if they are too basic for you, the course is considered completed when you finish all the quiz/challenges.

durul dalkanat
durul dalkanat
62,690 Points
def add_list_items
      ary = Array.new   
return ary
end

You can create any hash using {} but add the .to_a method to it. Then return hash