From: Steve Coltrin Date: 2000-11-30T00:10:02+09:00 Subject: [ruby-talk:6635] Re: Best way to convert a string to an array of numbers? "Hee-Sob Park" writes: > "Cullen J O'neill" wrote in message > news:gO2V5.192$6b.469@srvr1.engin.umich.edu... > > I have a string of numbers like: > > > > "2 3 3.5 5 1.2" > > > > What's the best way to convert this into an array like: > > > > [ 2, 3, 3.5, 5, 1.2 ] > > > How about > > a = s.split.collect {|x| eval x} Only if you can be sure s is not "2 3 3.5 exit 1.2" :) -spc