/* LikekotlinWhen.kt Copyright (c) Kari Laitinen http://www.naturalprogramming.com 2020-10-30 File created. 'when' expression in Kotlin replaces the switch-case construct that is common in many other languages. */ fun main() { print( "\n This program uses a when expression." + "\n Do you like the Kotlin programming language?" + "\n Please, answer Y or N : " ) val character_from_keyboard = readLine()!![ 0 ] when ( character_from_keyboard ) { 'Y', 'y' -> { print( "\n That's nice to hear. \n" ) } 'N', 'n' -> { print( "\n That is not so nice to hear. " + "\n I hope you change your mind soon.\n" ) } else -> { print( "\n I do not understand \"" + character_from_keyboard + "\".\n" ) } } print( "\n" ) }