Is there a way to reference member extension funct...
# announcements
m
Is there a way to reference member extension function?
Copy code
class A
class B {
    fun A.update(i: Int) {}
}
g
Yes,
Copy code
val b = B()
with(b) {
  A().update(42)
}
🧐 1
p
Very useful to scope extension functions so they don’t run wild on the global scope 🙂 Specially if
B
is an interface
m
@gildor This is use. Can we reference it?
For instance, for normal or inner we can reference either using normal or bounded:
Copy code
class B {
    fun fizz() {}
    inner class C {
        fun buzz() {}
    }
}

fun main() {
    val ref1 = B::fizz
    val ref2 = B()::fizz
    val ref3 = B.C::buzz
    val ref4 = B().C()::buzz
}
g
Method reference doesn’s supported for member extension functions
m
Great, that what I wanted to know 🙂