This is due to the ambiguity of the syntax:
val message = log()
{ message }
This code is parsed as if it were val message = log() { message }, that is log, called with lambda { message }as an argument. And the instruction val message = ...has a type Unit, so an error message.
To solve this problem, you can add a semicolon:
val message = log();
{ message }
source
share