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

211
Views
Kotlin Koans: sobrecarga de operadores

Estoy completando el ejercicio de comparación de Kotlin Koans y me pregunto por qué compareTo() es la función que se anula, pero compare() es la función que se usa.

¿Cómo se relacionan aquí las dos funciones?

 data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> { override fun compareTo(otherDate: MyDate): Int = when { year != otherDate.year -> year - otherDate.year month != otherDate.month -> month - otherDate.month else -> dayOfMonth - otherDate.dayOfMonth } } fun compare(date1: MyDate, date2: MyDate) = date1 < date2
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La función compare() allí solo muestra un marcador de posición "cómo usar compareTo() " sin un significado real. Puede cambiarlo a otros nombres como desee.

¿Cómo se relacionan aquí las dos funciones?

Una función con nombre aleatorio compare() llama a la función compareTo() de MyDate con el símbolo de comparación < .

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!