Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda