Assuming the @houses array is set up as follows:
house1.price = 10
house2.price = 20
house3.price = 30
@houses << house1
@houses << house2
@houses << house3
This is the starting point of our calculation and we want to find the average price of a house:
total = 0
average = 0
for h in @houses
total += h.price
end
average = total/@houses.size
This seems like quite a lot of typing just to get an average.
Is there a better way?