--f46d043bdfb8c73ab004acb6bda8 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Sep 10, 2011 at 9:16 AM, Harry Kakueki <list.push / gmail.com> wrote: > # I have this > arr [1.1, 2.2, 3.3], [4.1, 5.6, 6.8], [7.1, 8.7, 9.0], [10.0, 11.4, > 12.6]] > > # I want this [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] > > # This works. But, I want to find a way that is faster than this in 1 > or 2 lines of code. > # Any nice ideas how I can do it without 2 maps? > # Even if it is not faster, I would like to see how you would do it. > > p arr.map{|y| y.map{|z| z.to_i}} > > I would personally use maps, but to do it without mapping it would look like this. Or were you wanting to go completely procedural and see what it would look like without any iterators at all? pre [1.1, 2.2, 3.3], [4.1, 5.6, 6.8], [7.1, 8.7, 9.0], [10.0, 11.4, 12.6]] post rray.new pre.each do |inner_array| post << [] inner_array.each { |num| post.last << num.to_i } end post [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] # true --f46d043bdfb8c73ab004acb6bda8--