Is there a way of writing `infix` functions that a...
# announcements
r
Is there a way of writing
infix
functions that allows the left side to be implied by the context? For example, in
apply
🚫 1
d
you mean something like:
Copy code
infix fun <T: Any>  T.test(other: Any) {

}
?
r
If you're looking for something like:
Copy code
infix fun String.test(other: String) {
    ...
}
"A".apply {
    test "B"
}
Then no, it's not possible.
a
if the argument is a lambda then it would be sort of like an infix however
r
@Ruckus yeah, that’s exactly what I’m talking about
c
@rook this works for me:
Copy code
infix fun String.isSameAs(other: String): Boolean = (this == other).also { println(it) }
"SomeString".apply {
    isSameAs("Foo")
    isSameAs(this)
}
prints
false
then
true