When calling Range#step without a block, instead of returning an Enumerator, an array is returned. Why is this? I'm all for ActiveSupport extending behavior of core Ruby libraries, but to completely change the value that's returned seems wrong.
If this can't be changed, is there a way to opt out of this specific behavior?
=> #<Enumerator: 0..10:step(2)>
>> require 'active_support/core_ext'
=> [0, 2, 4, 6, 8, 10]
According to the code, it overrides Range#step to handle the case without blocks. I don't know why this code was added before, but could be to handle some weird Ruby cases in older versions, where it didn't handle this method without a block. This commit 99c6482 added it 5 years ago.
There's no way to opt-out of this particular behavior, unless you require all stuff you want manually. Anyway, I believe the monkey patch could be removed, as one could just call to_a yourself if required.
@jeremy thoughs on this one?
Remove blockless_step leave all that up to Ruby
@carlosantoniodasilva @jeremy I've just seen your comment Carlos. For me the blockless_step.rb code doesn't make sense anymore. If you feel that I'm wrong feel free to revert it :).
I'm just fine with the removal, thanks bro :)
You guys are damn fast! I was going to make a pull request if everyone agreed it could be removed; thanks!
@joshuaclayton sorry for stealing your commit so :(
@spastorino no worries, just glad it got fixed!