Has it ever been possible calling an extension fun...
# getting-started
m
Has it ever been possible calling an extension function this way?
Copy code
fun String.myFunction(param: Int) { }

// ...

"receiver".myFunction(5)

// but instead...
myFunction("receiver", 5)
I'm positive I was able to do that from Kotlin.
e
no. but if it were a value
Copy code
myFunction: String.(param: Int) -> Unit
instead (such as a property or function parameter), then
"receiver".myFunction(5)
and
myFunction("receiver", 5)
would be equivalent
đŸ€Ż 1
r
Not on a function call directly, but you can on lambdas or function references:
Copy code
fun String.myFunction(param: Int) {}

// ...

fun main() {
    val myFunction = String::myFunction
    
    "receiver".myFunction(5)

    // but instead...
    myFunction("receiver", 5)
}
Ah, beat me to it 🙂
m
Ah, that was probably what I was thinking about. Thanks.
v
Or you had Groovy in mind. 😄
k
Why is it allowed for lambdas?