Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda