Ruby Ruby Collections Build a Grocery List Program Build a Grocery List Program: Part 3

Nick Evershed
Nick Evershed
5,536 Points

Someone please explain this line of code

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

1 Answer

Tim Knight
Tim Knight
28,852 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.