On Nov 5, 8:08=A0am, Jags Rao <aquaj... / yahoo.com> wrote:
> hi guys
>
> i have a array like this for e.g
>
> [["0", "0", "0", "0", "0", "3", "3"],
> =A0["0", "0", "0", "0", "0", "3", "3"],
> =A0["0", "0", "0", "0", "0", "3", "3"],
> =A0["0", "3", "0", "0", "0", "0", "3"],
> =A0["0", "0", "0", "0", "0", "0", "3"]]
>
> how wud i convert to this
>
> [[0, 0, 0, 0, 0, 3, 3],
> =A0[0, 0, 0, 0, 0, 3, 3],
> =A0[0, 0, 0, 0, 0, 3, 3],
> =A0[0, 0, 0, 0, 0, 3, 3],
> =A0[0, 0, 0, 0, 0, 0, 3],
> =A0[0, 0, 0, 0, 0, 0, 3],
> =A0[0, 3, 0, 0, 0, 0, 3],
> =A0[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 =3D [["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 =3D aStrings.map{|i| i.map{|s| s.to_i}}
puts aStrings[0][0].class.to_s # =3D> String
puts aFixnums[0][0].class.to_s # =3D> Fixnum
puts aFixnums[0][0].integer?   # =3D> true (So a Fixnum is_a Integer)

Note that the last line asserts that a Fixnum object is indeed an
Integer

HTH,
Richard