Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Array#transpose

() -> ::Array[::Array[untyped]]
transpose → new_array

Returns a new array that is self as a transposed matrix:

Example
a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]]
a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]]

The elements of self must all be the same size.

Related: see Methods for Converting.

See also #to_s #union #to_h #uniq also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0