Calling a method with lambda + receiver param from Java


#1

Hi,

is it currently possible to call a Kotlin method which has a lambda parameter with receiver from Java? Something like

fun serviceProxy(init: ServiceProxySpec.() -> Unit)

?


#2

Yes, ServiceProxySpec is the parameter of init.


#3

I don’t quite understand

Calling from Kotlin it would look something like

serviceProxy {
    foo()
    bar()
}

But from Java? How would the call look like? Something like this?

.serviceProxy(s -> s
    s.foo()
    s.bar()
)

#4
FileNameKt.serviceProxy(s -> {
    s.foo();
    s.bar();
    return Unit.INSTANCE;
})