If you need to use the value inside the when state...
# getting-started
r
If you need to use the value inside the when statements, you could always just use a variable:
Copy code
fun count_von_count(n: Int) {
    val square = n * n
    when (square) {
        ...
    }
}
If you're function contains more than a single logical expression, I find it better to use a block body and avoid some of the more obtuse efforts to get your code on one line. It tends to make it cleaner and more readable.
👍 1