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

117
Views
Genérico vs Cualquier función en Kotlin

Cuál es la diferencia entre

 inline fun <reified T> T.TAG(): String = T::class.java.simpleName

y

 fun Any.TAG(): String = this::class.java.simpleName

¿Hay alguna diferencia entre usar genérico y Cualquiera como parámetro de función o como nombre de clase de función extendida?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hay una diferencia.

 inline fun <reified T> T.TAG1(): String = T::class.java.simpleName fun Any.TAG2(): String = this::class.java.simpleName

TAG1 obtendría el tipo de tiempo de compilación ya que el tipo de T se determina en el momento de la compilación, y TAG2 obtendría el tipo de tiempo de ejecución. this::class es similar a this.getClass() en Java.

Por ejemplo:

 val x: Any = "Foo"

x.TAG1() le daría Any::class.java.simpleName , y x.TAG2() le daría String::class.java.simpleName .

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!