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 Build a Grocery List Program: Part 3

Someone please explain this line of code

list["items"].each do |item|

1 Answer

Tim Knight
Tim Knight
28,888 Points

Hi Nick,

list["items"] is an Array defined through the create_list() method. So that particular line of code loops through each of the items within that array and then assigns the local variable item to each item as it is looped over.