The when statement 

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.21.5