mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
When is not a function, but an expression (#4603)
https://kotlinlang.org/docs/control-flow.html#when-expression
This commit is contained in:
parent
63a2c26029
commit
a0736c7a17
@ -297,7 +297,7 @@ fun helloWorld(val name : String) {
|
||||
else -> println("none of the above")
|
||||
}
|
||||
|
||||
// "when" can be used as a function that returns a value.
|
||||
// "when" can be used as an expression that returns a value.
|
||||
var result = when (i) {
|
||||
0, 21 -> "0 or 21"
|
||||
in 1..20 -> "in the range 1 to 20"
|
||||
|
Loading…
Reference in New Issue
Block a user