Ruby Language Multidimensional Arrays Array flattening


Example

Given a multidimensional array:

my_array = [[1, 2], ['a', 'b']]

the operation of flattening is to decompose all array children into the root array:

my_array.flatten

# [1, 2, 'a', 'b']