Peña, Botp
1/29/2007 1:13:00 AM
From: Fer# [mailto:fernando.mdelacueva@gmail.com] :
# irb(main):003:0> (0...arbitrary_number.to_s.length).map{|digit|
# arbitrary_number.to_s.split('')[digit]}
# => ["1","2","3"]
forgive my ignorance, but why are you splitting them and rebuilding back the array. I mean why not,
# arbitrary_number.to_s.split ''
# => ["1","2","3"]
and it works for signed and float too
# arbitrary_number=-123.45
=> -123.45
# arbitrary_number.to_s.split ''
=> ["-", "1", "2", "3", ".", "4", "5"]
kind regards -botp