Is there a way to declare a java method as infix for kotlin

Vinz243 :

Is there a way to declare a method from a java class so that it is callable as an infix function from kotlin, like this :

public class Foo {
  public void doFoo (String bar) {}
}

Then from a kotlin file

foo doFoo "bar"
Joe Clay :

As of Kotlin 1.3, no:

Since Java has no way of marking methods for which it makes sense to use the operator syntax, Kotlin allows using any Java methods with the right name and signature as operator overloads and other conventions (invoke() etc.) Calling Java methods using the infix call syntax is not allowed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=85279&siteId=1