Created
June 30, 2013 01:37
-
-
Save shotarok/5893421 to your computer and use it in GitHub Desktop.
My flatten function !!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myflatten(ary) | |
tmp = [] | |
ary.each { |e| | |
if e.is_a? Array then | |
tmp.concat myflatten(e) | |
else | |
tmp.push e | |
end | |
} | |
return tmp | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment