From: Daniel Nugent Date: 2006-02-13T06:56:14+09:00 Subject: Re: newbie question about blocks The problem you're seeing is that :each doesn't do anything with the return values of the block. What you want is :map or :collect (or their destructive forms :map! or :collect!). On 2/12/06, Jeppe Jakobsen wrote: > Hi, I want to square every element in my array using a block: > > a = (1..1000).to_a > a.each {|x| x**2} > > But this does not seem to work, it just outputs my array completely > unchanged :( > > -- > "winners never quit, quitters never win" > > -- -Dan Nugent