Could you give an example of that?
products.select { |product| product.type == 'x' }.map(&:price).reduce(:+)
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.products.lazy.select { |product| product.type == 'x' }.map(&:price).reduce(:+)
for a in x: pass
into a comprehension, you write: [pass for a in x]
Simple, right? So to convert for a in x: for b in y: pass
I obviously write: [pass for b in y for a in x]
Bzzt. Nope, you have to write it in middle-endian order to get the same behaviour.