From: Robert Feldt Date: 2001-10-11T09:09:31+09:00 Subject: [ruby-talk:22413] Re: list comprehensions alike Python ??? On Thu, 11 Oct 2001, Paul Prescod wrote: > Out of curiousity, what would the Ruby for this look like: > > >>> arr = [x*x for x in range(0,10) if x%2==0] > >>> arr > [0, 4, 16, 36, 64] > > A combination of filter and map? > One alternative is: irb(main):001:0> (0...10).select{|v| v%2==0}.map{|v| v*v} [0, 4, 16, 36, 64] but there are other. /Robert