Created
June 24, 2017 15:57
-
-
Save khunzohn/fbb88d3af2f53d7a4711a80de1d0def3 to your computer and use it in GitHub Desktop.
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
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