From: Mike Stok Date: 2002-02-05T04:27:48+09:00 Subject: Re: newbie: Array element conversion On Tue, 5 Feb 2002, Mark Probert wrote: > > Hello. > > I have an array of numbers as strings that I want to > convert to individual numbers. > > Naively, I tried > > ��������> a = ["100", "487", "23"] > ��������> x, y, z = a.each { |s| s.to_i } > > but I only get the strings back. I know that a[0].to_i > works but I am not sure how to get it to work over > each element of the array, correctly. x, y, z = a.collect{ |s| s.to_i } maybe? Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@starnix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.starnix.com/ | 75D2 9EC4 C1C0 0599 13DA