Skip to content

Instantly share code, notes, and snippets.

@makushline
Last active December 15, 2015 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makushline/1691e7013977f0f4f372 to your computer and use it in GitHub Desktop.
Save makushline/1691e7013977f0f4f372 to your computer and use it in GitHub Desktop.
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
@jmtame
Copy link

jmtame commented Dec 15, 2015

HIRE THIS GUY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment