From: moontoeki@... (Sung Moon)
Date: 2002-02-08T03:44:04+09:00
Subject: Re: newbie: Array element conversion
>Subject: newbie: Array element conversion
>From: Mark Probert probertm@nortelnetworks.com
>
>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.
use collect like
a =["100", "487", "23"]
z = a.collect { |s|
s.to_i
}
p z
sungjin moon