How do I filter by an enum class in kotlin? (just learning)
In the code below the enum class defined earlier in the file is PayStatus{PAID,UNPAID}.
fun nextRentDate(): LocalDate? {
return rentPaymentSchedule.
filter { it.value.paymentStatus is PayStatus.UNPAID}.
minBy { it.value.date.toEpochDay() }?.value?.date
}
I get the error: Kotlin:
Incompatible types: PayStatus.UNPAID and Enum
==(or even===here), notis. is is for type checking (instanceof in Java). kotlinlang.org/docs/reference/typecasts.html, kotlinlang.org/docs/reference/equality.html==but was getting a different error, the root problem was that I had defined enum class in both the state file, and the contract file, so it was getting overridden by the wrong file defined enum class. all sorted, thanks!!