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 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
PLUS
William Li
Courses Plus Student 26,858 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

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

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
Courses Plus Student 26,858 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
Courses Plus Student 26,858 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.

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