Array#flatten
Show archive.org snapshot
by default flattens an array recursively. To only flatten the array for e.g. one level, it takes an optional argument.
# Flattens the array recursively
>> [1, [2, [3]]].flatten
=> [1, 2, 3]
# Flattens the array the given number of times
>> [1, [2, [3]]].flatten(1)
=> [1, 2, [3]]
Posted to makandra dev (2015-02-20 13:51)