I am using the following when
-statement in Kotlin:
when(name) {
"Sun" -> print("Sun is a Star")
"Moon" -> print("Moon is a Satellite")
"Earth" -> print("Earth is a planet")
}
And I have a function foo()
.
This function should be executed for every case of the when
-statement.
I tried:
when(name) {
"Sun" -> print("Sun is a Star")
"Moon" -> print("Moon is a Satellite")
"Earth" -> print("Earth is a planet")
foo()
}
But I get an error.
How do I make a foo()
function call within the when
-statement?