In Kotlin, assignments are not expressions. Assignment expressions have few real use cases and, as a rule, impair code readability, not to mention if (a = b) errors, therefore they are not taken into account. You can find more comments from the Kotlin team in this discussion .
It is actually not possible to get the value returned by the Java installer using the property = value syntax, and the workaround you described is a valid way to get that value.
Kotlin property setters, in turn, cannot return a value, and, for example, the general Java idiom of this return value for a call chain is expressed using Kotlin with a receiver :
MyClass c = new MyClass() .setFoo(x) .setBar(y) .setBaz(z);
Kotlin (using apply ):
val c = MyClass().apply { foo = x bar = y baz = z }
See also:
source share