On Sun, Sep 11, 2011 at 11:49 PM, botp <botpena / gmail.com> wrote:

> On Mon, Sep 12, 2011 at 12:12 PM, Josh Cheek <josh.cheek / gmail.com> wrote:
> > 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 = Array.new
> > pre.each do |inner_array|
> >  post << []
> >  inner_array.each { |num| post.last << num.to_i }
> > end
>
> luv this inject code. hope matz can enhance inject further
>
>  pre.inject([]) do |new_array,inner_array|
>   new_array + [inner_array.map(&:to_i)]
>  end
> #=> [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
>
> kind regards -botp
>
>
IDK, I feel like most places #inject is used, #with_object would be a better
choice.

pre.each.with_object([]) do |inner_array, new_array|
  new_array << inner_array.map(&:to_i)
end