3 ms·
I guess it's a personal style choice, the Python code is more performant(less iterations over the data set), but I like the ruby version better.
by K0nserv 10y ago
I guess it's a personal style choice, the Python code is more performant(less iterations over the data set), but I like the ruby version better.
- ezrast 10y agoIt's only one iteration if you throw a .lazy in there: products.lazy.select { |product| product.type == 'x' }.map(&:price).reduce(:+)