Skip to content

Instantly share code, notes, and snippets.

@metacoder87
metacoder87 / Theorem Array Flaten
Created July 14, 2019 10:14
Learning experience for the .flatten built in Ruby method. How it works...
# The goal of this code is to compress nested Arrays into a single Array, just as the .flatten method.
class Array
#this method will make it possible to use my own array flattening method in Ruby by saving this method to the Array class.
def make_it_flat(g = nil)
g ? flatten_all(self, g) : flat_anyway(self)
#checking if g has value or not