And in Python you can write something like:
sum([p.price for p in products if p.type == "x"])
Excuse untested code from phone, but I like it better than the ruby version.