From: "David A. Black" Date: 2009-09-14T12:11:25+09:00 Subject: Re: [1,2,3].map.with_object(3){|v|v+3} #=> 3 Is this a bug? Hi -- On Mon, 14 Sep 2009, ErMaker wrote: > At ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-mswin32_90] > > Ruby runs like this. > >>> [1,2,3].map.with_object(3){|v|v+3} > => 3 >>> [1,2,3].each.with_object(3).map{|v|v+3} > => [4, 5, 6] > > > I think that is better to use. > >>> [1,2,3].map.with_object(3){|v|v+3} > => [4, 5, 6] > > Is it a bug? I don't think so. with_object always returns its argument, or an enumerator, as far as I know. But I'm not 100% sure I'm understanding what part you think might be a bug. 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)