From: Michael Linfield Date: 2008-05-15T02:09:19+09:00 Subject: Re: Convert integer to array? Mikel Lindsaar wrote: > On Mon, May 12, 2008 at 6:36 PM, Nadim Kobeissi wrote: >> Let's say I have: >> x=1234 >> How can I convert that to the follow array: >> x=[1, 2, 3, 4] Most of the other ways are better, but none-the-less: x=1234 array = [] results = x.to_s.split('') results.each{|x| array << x.to_i} array #=> [1,2,3,4] Regards, - Mac -- Posted via http://www.ruby-forum.com/.