Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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"
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

You can add an infix extension to get that syntax from Kotlin:

infix fun Foo.doFoo(bar: String) {
    return doFoo(bar)
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!