From: Anton Ivanov Date: 2008-09-11T05:00:42+09:00 Subject: Re: Redefe each to include each_with_index and arity=2 > I would like to ask others if they think having each overloaded to take > either |item| or |item,index| would be a general language improvement. > Also, for greatest generality should this proposed redefinition of each > be made to the class Array or to the enumerator mixin or somewhere else? Like you, I've wondered why each could not do both things. On the one hand it would be nice if it supported the index functionality. However, it is really a breaking change. Consider what a and b are assigned currently at each iteration of the following, and what they would be assigned under your proposal. [[1,2], [3,4]].each {|a,b|} To answer your second question, each() must know the details of the container, and so it cannot be in a mixin. The Enumerable mixin defines functionality in terms of 'each' which must be supplied by the class into which you mix it in. -- Posted via http://www.ruby-forum.com/.