I have a class called Product, which contains a name, price and count.
In another class called Shop (including the class Product), I initialize with an empty array. Then a add product to this array using the method push.
The problem happens to the method to_s of in the Shop class :
def to_s
string = "Products in the shop:\n"
@list.each do |list|
#### how can i get access to the attributes of product like @list.name or something like that ? I have tried loads of different methods but i cant get access to my attributes. (the array doesnt recognize the product class)
puts @list.name
end
If I create a Product without using Array, I can access to the attributes - I guess the problem comes because of the Array...
endin your code the end of theeachblock or the end of thedef to_sblock?ends. =)