3 ms·
Additionally, unless you use a lazy operator, the Ruby code iterates twice, and allocates two arrays. With n > 5 and more chained operations this can get painfu
by lloeki 7y ago
Additionally, unless you use a lazy operator, the Ruby code iterates twice, and allocates two arrays. With n > 5 and more chained operations this can get painful. Using lazy enums solves that but may introduce other unsuspected behaviours due to laziness.
Still, being reasonably functional can have surprisingly good effects despite extra allocations / iterations.