Created
August 25, 2016 20:39
-
-
Save themonster2015/278b304a42b5247d9583ead6bd519108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flattify(array) | |
array.each_with_object([]) do |element, flattened| | |
flattened.push *(element.is_a?(Array) ? flattify(element) : element) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment