I have troubles with a function in Kotlin that should return Unit, but due to a usage of another function returning a Boolean, there is a type mismatch.
Here is a co
As another alternative, you could make a higher order function that swallows the output of the function returning a value:
fun consume (fn: () -> Any): Unit { fn() }
Giving:
fun foo(bar: Int): Unit = when(bar) { 0 -> println("0") else -> consume { printAndReturnTrue(bar) } }