Created
December 18, 2010 00:16
-
-
Save photomattmills/745953 to your computer and use it in GitHub Desktop.
This method will go through all the children in a multidimensional array.
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
array = [:first,:first,[:second,:second,[:third,:third,[:fourth,:fourth]]]] | |
def walk(array) | |
if array.class == Array | |
array.each do |item| | |
if item.class == Array | |
item.each { |i| walk(i) } | |
else | |
puts item | |
end | |
end | |
else | |
puts array | |
end | |
end | |
walk(array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment