Built-in method

Año bisiesto
Año bisiesto en Kotlin
import java.time.*

data class Year(val year: Int) {
    val isLeap = LocalDate.of(year, Month.FEBRUARY, 28).isLeapYear
}

This may be considered a "wicked cheat" for this exercise, by simply passing the year into the isLeap() method of the Year class. Although it is not in the spirit of this exercise, isLeap() would be the idiomatic way to determine if a year is a leap year in the "real world".

23 de septiembre de 2026 · ¿Te ha resultado útil?