From: Avi Bryant Date: 2001-10-11T08:33:14+09:00 Subject: [ruby-talk:22406] Re: list comprehensions alike Python ??? On Thu, 11 Oct 2001, markus jais wrote: > with python code like this: > > l = [x * x for x in range(1, 11)] > > I get a list with squares of all numbers of 1-10 > > in ruby I could do this with the following code: > > a = Array.new > (1..10).each { |elem| > a[elem-1] = elem * elem > } > > is there an even shorter way do to this in ruby?? a = (1..10).map{|x| x*x}