Ruby array-methods reference.
Returns a new array that is a recursive flattening of self to the specified depth. Supports integer depth control, nil for full flatten, and negative values.
array.flatten(depth = nil)