Issue #9140 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


This is interesting because I noticed the *args in the documentation but it wasn't documented what it means. So I tried it but in a different context (adapting from your example):

%w(foo bar baz).each_with_index("|") {|s, i| p [s, i] }
ArgumentError: wrong number of arguments (1 for 0)
        from (irb):3:in `each'
        from (irb):3:in `each_with_index'
        from (irb):3
        from /home/rodrigo/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'

That's why I assumed it didn't accept any arguments.
----------------------------------------
Feature #9140: Allow each_with_index to get start index
https://bugs.ruby-lang.org/issues/9140#change-43085

Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: lib
Target version: 


Is it possible for array.each_with_index(1){|el, i| ... } to be equivalent to array.each.with_index(1){...}?

Sometimes the application-domain index starts with 1, not 0. Currently each_with_index doesn't accept any arguments, so it wouldn't be backward incompatible if the start index defaults to 0.


-- 
http://bugs.ruby-lang.org/