Skip to content

Instantly share code, notes, and snippets.

@CodingAnarchy
Created September 25, 2018 15:56
Show Gist options
  • Save CodingAnarchy/569e0ecc326b8faa152debc812f157a9 to your computer and use it in GitHub Desktop.
Save CodingAnarchy/569e0ecc326b8faa152debc812f157a9 to your computer and use it in GitHub Desktop.
Recursive flatten
def flatten(array, results = [])
array.each do |element|
if element.class == Array
flatten(element, results)
else
results << element
end
end
results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment