I would like my Enum values to be comparable with other types, for instance, String
. I am not entirely sure why it complains and what the error means.
enum class Fruits(val value: String): Comparable<String>{
Apple("apple"),
Orange("orange");
override fun compareTo(other: String): Int {
return compareValuesBy(this.value, other)
}
}
val test: Boolean = Fruits.Apple == "apple"
Error says:
Type parameter T of 'Comparable' has inconsistent values: Fruits, String