Skip to content

Instantly share code, notes, and snippets.

@HoneyryderChuck
Created August 1, 2016 13:07
Show Gist options
  • Save HoneyryderChuck/8b2306d0cd33c064dfcf09dd62b267da to your computer and use it in GitHub Desktop.
Save HoneyryderChuck/8b2306d0cd33c064dfcf09dd62b267da to your computer and use it in GitHub Desktop.
alternative flatten
def flatten(a, elems=[])
a.each do |e|
case e
when Array then flatten(e, elems)
else elems << e
end
end
el
end
#=> flatten([[1, 2,[3, 5]], 6])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment