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

236
Vistas
Which best practice in Kotlin for get class simple name

I'm using both ways for get the simple class name in Kotlin, but I don't know which the best. I often use for logging, so I use only into current class, therefore I use this in example bellow. Someone help me, please.

this::class.simpleName

OR:

this.javaClass.simpleName
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It's probably more important to pick one method and be consistent. I doubt there is an established best practice on this particular matter (though you never know). It's also unlikely either of these perform better or worse than the other.

That being said, this.javaclass will only be available when running on the JVM: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/java-class.html

Whereas this::class I believe is commonly available whether you are targeting JVM, JS or Native. As a rule of thumb, I tend to favor whichever is common across all targets when there is a choice.

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