From: RichardOnRails Date: 2008-11-06T06:43:18+09:00 Subject: Re: convert string array to interger array in in one line On Nov 5, 8:08 am, Jags Rao wrote: > hi guys > > i have a array like this for e.g > > [["0", "0", "0", "0", "0", "3", "3"], >  ["0", "0", "0", "0", "0", "3", "3"], >  ["0", "0", "0", "0", "0", "3", "3"], >  ["0", "3", "0", "0", "0", "0", "3"], >  ["0", "0", "0", "0", "0", "0", "3"]] > > how wud i convert to this > > [[0, 0, 0, 0, 0, 3, 3], >  [0, 0, 0, 0, 0, 3, 3], >  [0, 0, 0, 0, 0, 3, 3], >  [0, 0, 0, 0, 0, 3, 3], >  [0, 0, 0, 0, 0, 0, 3], >  [0, 0, 0, 0, 0, 0, 3], >  [0, 3, 0, 0, 0, 0, 3], >  [0, 0, 0, 0, 0, 0, 3], > > i.e a string array to integer array in 1 line if possible > > pls help > -- > Posted viahttp://www.ruby-forum.com/. Maybe this is a little clearer: aStrings = [["0", "0", "0", "0", "0", "3", "3"], ["0", "0", "0", "0", "0", "3", "3"], ["0", "0", "0", "0", "0", "3", "3"], ["0", "3", "0", "0", "0", "0", "3"], ["0", "0", "0", "0", "0", "0", "3"]] aFixnums = aStrings.map{|i| i.map{|s| s.to_i}} puts aStrings[0][0].class.to_s # => String puts aFixnums[0][0].class.to_s # => Fixnum puts aFixnums[0][0].integer? # => true (So a Fixnum is_a Integer) Note that the last line asserts that a Fixnum object is indeed an Integer HTH, Richard