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. You can install minitest in the command line by typing:
$ gem instal minitest
You can try the method directly in the ruby console
Start irb
$ irb
Require ArrayUtil
> require './array_util.rb'
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