Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby Array Flatten
def flatten(array, accum=[])
array.each do |a|
if a.is_a? Array
flatten(a, accum)
else
accum.push(a)
end
end
return accum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment