3 ms·
It's only one iteration if you throw a .lazy in there: products.lazy.select { |product| product.type == 'x' }.map(&:price).reduce(:+)
by ezrast 10y ago
It's only one iteration if you throw a .lazy in there:
products.lazy.select { |product| product.type == 'x' }.map(&:price).reduce(:+)