Is it possible to do something like this?
customer1.shopping_cart.each do |item|
puts("#{item.name}")
The Item
class has an attr_reader
for the instance variable name.
Is it possible to do something like this?
customer1.shopping_cart.each do |item|
puts("#{item.name}")
The Item
class has an attr_reader
for the instance variable name.
This will put names for every item from the
customer1.shopping_cart
collection (presumably array or set)UPD: A bit more idiomatic syntax: