Requires Ruby 1.9.2 or above. This implementation adds Array#my_flatten to an Array object, which is itself a replica of Array#flatten which is done in C.
Make sure you have minitest gem installed: $ gem install minitest. Then run:
ruby my_flatten_test.rb