From: Robert Klemme Date: 2008-11-30T16:54:51+09:00 Subject: Re: Enumerable#select used to return actual values On 30.11.2008 04:46, Mike Austin wrote: > I'm pretty sure select used to use the actual value of the called block, > instead of treating it as just a truthy/falsey boolean. I am pretty sure it did never. Maybe you have a combination with to_enum in mind or rather inject? > I know this is > unconventional, but it's a really nice, compact way of expressing map > and filter in one shot, like list comprehension: > > (1..10).select { |a| a * a if a > 5 } > > Was it ever there, or did I just have a dream about it? It's easy to > implement... just wondering. Maybe 1.9 has a nifty trick, I don't use it that often yet. As said, inject is always a good candidate for this: irb(main):005:0> (1..10).inject([]) {|r,a| r << (a*a) if a > 5; r} => [36, 49, 64, 81, 100] Kind regards robert