3 ms·
The note about the idiomatic Ruby version of this (each on a range) being slower than the tested version (while loop) is very interesting. This looks like an o
by caf 11y ago
The note about the idiomatic Ruby version of this (each on a range) being slower than the tested version (while loop) is very interesting.
This looks like an opportunity for the Ruby interpreter to optimise: if the range is excessively large, it could decide itself to loop over the bounds rather than instantiating the entire range.
- cremno 11y agoIt doesn't. A range just knows if it's exclusive, and its beginning and end value. That line is also not really idiomatic. It's just trying to be.