Skip to content

Instantly share code, notes, and snippets.

@khunzohn
Created June 24, 2017 15:57
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 khunzohn/fbb88d3af2f53d7a4711a80de1d0def3 to your computer and use it in GitHub Desktop.
Save khunzohn/fbb88d3af2f53d7a4711a80de1d0def3 to your computer and use it in GitHub Desktop.
fun Int.mapToWord(): String {
val word: String
when (this) { // this refers to Int with its scope limited to the method level
0 -> word = "Zero"
1 -> word = "One"
2 -> word = "Two"
// 3,4,5,6,7,8,9
else -> word = "Invalid Digit Range"
}
return word
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment