On Thu, 13 Apr 2006, Bruce Woodward wrote:

> a = [ 1,2,3,4,5 ]
>
> b = a.map_if { |i|
>  (i % 2 != 0) and (i * 10)
> }
>
> p b ##  [10, 30, 50]

inject is very powerfull:

   harp:~ > cat a.rb
   a = 1 .. 5
   b = a.inject([]){|a,i| i[0] == 1 ? a.push(i * 10) : a}
   p b

   harp:~ > ruby a.rb
   [10, 30, 50]

regards.

-a
-- 
be kind whenever possible... it is always possible.
- h.h. the 14th dali lama