Last active
December 15, 2015 00:27
-
-
Save makushline/1691e7013977f0f4f372 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 flatten(input) | |
raise ArgumentError.new("Only arrays are allowed") if !input.is_a?(Array) | |
output = [] | |
input.each do |element| | |
if element.is_a?(Array) | |
output += flatten(element) | |
else | |
output << element | |
end | |
end | |
return output | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HIRE THIS GUY