Skip to content

Instantly share code, notes, and snippets.

@sjain
sjain / array_flattener.rb
Created September 27, 2019 04:11
Array flattener
#!/usr/bin/env ruby
require 'minitest'
class ArrayFlattener
def perform(nested_array)
nested_array.inject([]) do |result, item|
if item.is_a?(Array)
result.push *self.perform(item)
else