The when statement here is the same as Java's switch statement, but with concise code as follows:
var word : String = when(letter) {
"A" -> "Apple";
"B" -> "Ball";
"C" -> "Cat";
"D" -> "Dog";
else -> "Don't Know";
}
The else keyword is used to specify default values in case no match is found.