Skip to content

Instantly share code, notes, and snippets.

@daifu
Last active August 29, 2015 14:06
Show Gist options
  • Save daifu/e12ab909987f0ccfc441 to your computer and use it in GitHub Desktop.
Save daifu/e12ab909987f0ccfc441 to your computer and use it in GitHub Desktop.
Flatten An Array
def flatten(ary)
ret = []
ary.each do |sub_ary|
if sub_ary.is_a?(Array)
ret += flatten(sub_ary)
else
ret << sub_ary
end
end
ret
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment