Infix precedence


#1

Is there anyway to get the following to compile without using parenthesis.

  infix fun String.b(k: Int) {  }
  infix fun String.e(b: Boolean): Int = 0

  "a" b ("c" e false) // compiles
  "a" b "c" e false // fails

I was hoping the compiler would look ahead and see that the infix e can work for c and false and give the value that b needs without me having to specify the order via parenthesis.


#2

What if I wrote a code like this:

  infix fun String.b(s: String):String { return this}
  infix fun String.e(b: Boolean): Int = 0

Now I can do:

"a" b "c" e false

But this calculation is from left to right.
In most languages we read and write from left to right.


#3

it is equal to

"a".b("c").e(false)

#4

That’s not infix though is it.


#5

Thanks, but should have added I can’t change the original methods. I guess its just a limitation I’ll have to accept.