``` class Dummy { fun foo() = println("Hi") } ...
# announcements
v
Copy code
class Dummy {
    fun foo() = println("Hi")
}
fun Dummy.apply(f :Dummy.() -> Unit) = f()
Dummy().apply({ foo() })
How does
Dummy.() -> Unit
know how it needs to dispatch the function call?
e
Isn’t the
f()
already means a function call?
b
It doesn’t know, it just know what’s required and what’s returned by the function call. As @edwardwongtl commented, the
f
variable has to be invoked to dispatch the function call.