Skip to content

Instantly share code, notes, and snippets.

@clauda
Created May 20, 2016 02:20
  • Select an option

Select an option

Ruby #flat
class Array
def flat
each_with_object([]) do |element, init|
init.push *(element.is_a?(Array) ? element.flat : element)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment