Created
March 7, 2018 17:03
-
-
Save stephenbaidu/7258cd7c74b87cb574c0431a9d5ff94f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 flatten(element) | |
return [element] unless element.is_a?(Array) | |
element.map{|e| flatten(e) }.inject(:+) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment