-
-
Save anonymous/a63b531bb9c3d6c4e81f to your computer and use it in GitHub Desktop.
upcasing recursively
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
a = [ "foo", "bar", ["bax", ["quux", "yay"]]] | |
def recurse_upcase arr | |
arr.inject([]){ | |
|arr1, v| | |
arr1.push(v.kind_of?(Array) ? recurse_upcase(v) : v.upcase); arr1 | |
} | |
end | |
p recurse_upcase(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment