On Thu, Oct 11, 2012 at 8:14 PM, Anna B. [email protected] wrote:
y = “#{x}”.scan(/./)
Better
y = x.to_s.scan /./
You can also do this numerically
irb(main):008:0> x = 113453
=> 113453
irb(main):009:0> y = []
=> []
irb(main):010:0> while x > 0; x, b = x.divmod 10; y.unshift b; end
=> nil
irb(main):011:0> y
=> [1, 1, 3, 4, 5, 3]
respectively
irb(main):015:0> x = 113453
=> 113453
irb(main):016:0> y = []
=> []
irb(main):017:0> while x > 0; x, b = x.divmod 10; y.unshift b.to_s; end
=> nil
irb(main):018:0> y
=> [“1”, “1”, “3”, “4”, “5”, “3”]
or even
irb(main):030:0> x = 113453
=> 113453
irb(main):031:0> y = []
=> []
irb(main):032:0> while x > 0; y.unshift((x, b = x.divmod 10).last.to_s);
end
=> nil
irb(main):033:0> y
=> [“1”, “1”, “3”, “4”, “5”, “3”]
Now, after using y for my nefarious purposes, I would like to re-convert
the elements (still containing one digit each) into an integer.
You make me curious…
I don’t mind writing a routine for it, but was wondering if there’s some
magical way to do it quicker 
No magic needed
z = y.join.to_i
Kind regards
robert