Hi Folks , How do I reference `this` inside SAM in...
# general-advice
a
Hi Folks , How do I reference
this
inside SAM interface ? Pasting code as I don’t know why I am not getting option to attach Images . this@Observer gives error
'this' is not defined in this context
Copy code
val observer = Observer<T> {
        data = it
        latch.countDown()
        this@getOrAwaitValue.removeObserver(this@Observer)
    }
e
you will need to write it as an object,
Copy code
val observer = object : Observer<T> {
    override fun ???() {
        removeObserver(this)
    }
}
a
That sucks 😕 , what is the reason we cannot use this inside SAM ? Seems completely possible.
e
lambdas do not have identity