I wrote a class with a custom :flatten method in Ruby similar to [1,2,3].flatten This method recursively flatten an Array
You'll need:
- ruby
- minitest
The test was written using Minitest
gem instal minitest
You can test this directly in the ruby console
- Start irb
$ irb
- Require ArrayUtil
require './array_util'
- Pass the array as an argument of ArrayUtil flatten method
ArrayUtil.flatten([1,2,3])
To run the test in the command line type:
$ ruby array_util_test