Skip to content

Instantly share code, notes, and snippets.

@zeitnot
Last active September 28, 2018 17:55
Show Gist options
  • Save zeitnot/b62c7c623071f7d71fce8df870b91374 to your computer and use it in GitHub Desktop.
Save zeitnot/b62c7c623071f7d71fce8df870b91374 to your computer and use it in GitHub Desktop.
Ruby flatten array
module FlattenArray
def self.flatten(ar, flatten_array = [])
ar.each do |el|
next unless el
if el.kind_of?(Array)
flatten(el,flatten_array)
else
flatten_array << el
end
end
flatten_array
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment