We can do it
val obj = Obj() with (obj) { objMethod1() objMethod2() }
But is there a way to do this?
val obj = with(Obj()) { objMethod1() objMethod2() }
To solve the usual case when you create an object and call several methods to initialize its state.
kotlin
Yuri geinish
source share