Excerpts from Michael Fellinger's message of Sat May 23 17:38:35 +0300 2009:
> On Sat, 23 May 2009 10:20:50 +0900
> Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> 
> > Before accepting the proposal, could you explain why we _should_
> > return the original string?  We haven't defined the return value of
> > each_char yet.
> > 
> >                             matz.
> 
> string = 'foo'
> 
> string.object_id == string.each_codepoint{|x|}.object_id
> # => true
> string.object_id == string.each_byte{|x|}.object_id
> # => true
> string.object_id == string.each_line{|x|}.object_id
> # => true
> string.object_id == string.each_char{|x|}.object_id
> # => false
> 
> I was hoping for a little bit of consistency as well.

Also true for Array#each and so on. Whichever way it goes,
they should all be the same.

Philosophically, returning self from a non-mutating iterator
is the most straightforward thing to do and makes it possible
to avoid the cost of the dup.


--
Magic is insufficiently advanced technology.