From: Rick DeNatale Date: 2009-12-11T00:26:02+09:00 Subject: [ruby-core:27129] Re: #to_enum ignores block? On Thu, Dec 10, 2009 at 9:58 AM, Roger Pack wrote: >> The whole purpose of to_enum is to return an Enumerator instance. >> The block has no meaning and is ignored, it's what the docs and source say. >> What did you expect it to do? > > I would expect it to act like a filter. >>> (1..3).to_enum {|n| n*2}.to_a > => [1, 4, 9] Why not just ruby-1.9.1-p376 > (1..3).map {|n| n* 2}.to_a => [2, 4, 6] or even ruby-1.9.1-p376 > (1..3).map {|n| n* 2} => [2, 4, 6] or if you REALLY wanted those results: ruby-1.9.1-p376 > (1..3).map {|n| n**2} => [1, 4, 9] -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale