A Ruby refinement to demonstrate flattening of a nested array without using
Array#flatten. Flattening logic is identical to my original implementation done as a Ruby module.
Array#custom_flatten when used as a refinement; one advantage to using a refinement is not having to check for non-array argument types. I'd be less inclined to use refinements in a production app given they haven't gained a lot of traction in the Ruby community, but I believe they're good for experimentation.
using FlattenRefinement [1, [2, ]].custom_flatten => [1, 2, 3]
Code was developed using Ruby 2.3.1. To run tests, run
bundle install and
bundle exec ruby flatten_refinement_test.rb