From: Derek Wyatt Date: 2005-09-22T23:52:28+09:00 Subject: Re: Parsing one-liners w = input_string.split(/,\s*/).map { |n| n.to_f } Regs, D email55555@gmail.com wrote: > If your numbers are *true* floats (for example 123.0 instead of 123), > then you could try this: > > w = eval("[#{input_string}]") > > > Kevin Olbrich wrote: > >>The problem: >> read in a string containing an arbitrary number of comma separated >>numbers and convert it to an array of numbers. >> >>It seems like this could be a one-liner, but the best I can get is two... >> >>w=input_string.split(/,\s*/) >>w.each_index {|n| w[n]=w[n].to_f} >> >>Anyone know a one-liner for this? >> >>_Kevin > > > > -- Derek Wyatt - C++ / Ruby / Unix Programmer http://derekwyatt.org