I have the following code:
class Presenter {
private var view : View? = null
fun attachView(view: View) = this.view = view
fun detachView() = view = null
}
I know that I can simply write:
class Presenter {
var view : View? = null
}
and then in the code just call presenter.view = View()and presenter.view = nullinstead of attachView/ detachView. But I think this is much less readable.
So why can't I use assignments as expression bodies in Kotlin? Why is assignment not just a type expression Unit?
source
share