Skip to content

Instantly share code, notes, and snippets.

@themonster2015
Created August 25, 2016 20:39
Show Gist options
  • Save themonster2015/278b304a42b5247d9583ead6bd519108 to your computer and use it in GitHub Desktop.
Save themonster2015/278b304a42b5247d9583ead6bd519108 to your computer and use it in GitHub Desktop.
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