In Ruby 1.8.7 and prior, Enumerable::each_with_index
did not accept any arguments. In Ruby 1.9, it will accept an arbitrary number of arguments. Documentation/code shows that it simply passes those arguments along to ::each
. With the built in and standard library Enumerables, I believe passing an argument will yield an error, since the Enumerable's ::each
method isn't expecting parameters.
So I would guess this is only useful in creating your own Enumerable in which you do create an ::each
method that accepts arguments. What is an example where this would be useful?
Are there any other non-obvious consequences of this change?