When I create an infix function, can I create an i...
# getting-started
v
When I create an infix function, can I create an infix function for an argument function and thus chain two infix functions? For example, the 3rd party lib I'm using has this
Copy code
interface SelenideElement {
  SelenideElement should(Condition condition)
}
I made the following infix function
Copy code
infix fun SelenideElement.should(condition: Condition) = this.should(condition)
Next, I want to create an infix function for the one from the Condition class. In the lib it is defined as this:
Copy code
public abstract class Condition {
  public static Condition text(String text) {
    return new Text(text);
  }
}
I tried this
Copy code
infix fun Condition.text(message: String) = Text(message)
but in the end, it doesn't work like I would like it to be. My end goal is to have the following syntax:
Copy code
selenideElement should text "hello"
If I don't override these functions, I use them as follows:
Copy code
selenideElement.shoould(text("hello"))
w
Infix functions always have a left and a right side. You can't call
text("hello")
using infix.
v
Ehh..