2017-04-26
Do NOT enumerate Enumerators
During a take on a Euler Problem, I stumbled upon a quirky behaviour:
(3..100).step(2)
=> #<Enumerator: ...>so you can do something like this, neglecting .each:
(3..100).step(2) { |e| e.nil? }which is a tiny bit faster than using each for iterating.
← Previous Post | Next Post →