Skip to content

Instantly share code, notes, and snippets.

@bsideup
Last active August 29, 2015 14:14
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
def fact(num) {
return match(num) {
when String then fact(num.toInteger())
when(0 | 1) then 1
when 2 then 2
orElse it * fact(it - 1)
}
}
assert fact("5") == 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment