Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's only one iteration if you throw a .lazy in there:

products.lazy.select { |product| product.type == 'x' }.map(&:price).reduce(:+)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: