From: "David A. Black" Date: 2009-09-16T05:04:49+09:00 Subject: Re: .map.with_object(3){|v|v+3} #=> 3 Is this a bug? Hi -- On Wed, 16 Sep 2009, 7stud -- wrote: > 7stud -- wrote: >> The next call in the method chain is with_object(): >> >>> [1,2,3].map.with_object(3){|v|v+3} >> >> and ***regardless of the iterator that with_object is attached to***, >> when >> with_object() is called with a block, with_object returns its argument, >> which in this case is 3. > > That isn't accurate, though. In this case with_object isn't attached to > an iterator--it's attached to an enumerator. So I guess I should have > simply said, > > When with_object is called with a block, with_object returns its > argument. > > and avoided the issue of how ruby allows you to chain enumerators to > both iterators and other enumerators. I don't think it does; with_object is an instance method of Enumerator. David -- David A. Black, Director Ruby Power and Light, LLC (http://www.rubypal.com) Ruby/Rails training, consulting, mentoring, code review Book: The Well-Grounded Rubyist (http://www.manning.com/black2)