Is it idiomatic kotlin? ```val check = true when(...
# codereview
e
Is it idiomatic kotlin?
Copy code
val check = true

when(check) {
    true -> println("it's true")
    false -> println("it's false")
}
m
For a boolean,
if
is the more readable choice.
When
is better for completeness check on enum/sealed class, or those cases where your
if
has at least 3 branches.
e
That was my assumptions, but is it common sence or written somewhere?
c
I don't know if it's been written down anywhere but it's implied. One advantage of the language is being concise, using the when is not as concise as say...
Copy code
if (check) println("it's true") else println("it's false")
d