Skip to content

Instantly share code, notes, and snippets.

@stephenbaidu
Created March 7, 2018 17:03
Show Gist options
  • Save stephenbaidu/7258cd7c74b87cb574c0431a9d5ff94f to your computer and use it in GitHub Desktop.
Save stephenbaidu/7258cd7c74b87cb574c0431a9d5ff94f to your computer and use it in GitHub Desktop.
def flatten(element)
return [element] unless element.is_a?(Array)
element.map{|e| flatten(e) }.inject(:+)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment