Array#flatten with depth argument is useful.
[, , [, 4]].flatten(1) #=> [1, 2, , 4]
That's been available since ruby 1.8.7, but older ruby such as ruby 1.8.6 doesn't support it.
Here is the pure-ruby implementation of
Array#flatten. Use it in case.
I used it for my library
spawn-for-legacy to support ruby 1.8.6.
Rails programmers don't need this code. Rails now only supports ruby newer than 1.8.7.