Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2016 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a63b531bb9c3d6c4e81f to your computer and use it in GitHub Desktop.
Save anonymous/a63b531bb9c3d6c4e81f to your computer and use it in GitHub Desktop.
upcasing recursively
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