From: Avi Bryant Date: 2001-10-11T09:08:32+09:00 Subject: [ruby-talk:22412] 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? sure: arr = (0..10).collect{|x| x*x}.select{|x| x.even?}