samuel
12/15/2020, 2:04 PMclass SomeClass() {
infix fun SomeClass.someFunction (someParam: SomeType) {
// some code
}
}
fun inSomeClass(action: SomeClass.() -> Unit) {
SomeClass().action()
}
inSomeClass {
this someFunction "param"
someFunction "param" // Receiver could possibly implied
}louiscad
12/15/2020, 10:20 PMsomeFunction(param) works, even if the function has the infix modifier.
I'm wondering about the implications of having this "prefix" syntax and the impact on code readability and correctness.samuel
12/16/2020, 9:07 AMthis would be nice to have. I think it would be similar to the way we can use extensions without explicitly specifying the receiver this for example:
someInstance.apply{
someExtension("someParam")
this.someExtension("someParam")
}
Given that the receiver is unambiguous in this case, i would think it would not have much of a negative impact imho