ursus
11/20/2021, 3:55 PMinterface Id : Comparable<Id> {
val value: String
override fun compareTo(other: Id): Int = value.compareTo(other.value)
fun toString(): String = value
}
but it complains 'toString' hides member of supertype 'Comparable' and needs 'override' modifier
which is nonsense, but if I remove the comparable, then it complains that im hiding Any
is this possible?Ayfri
11/20/2021, 3:57 PMtoString
method, because it is already present in Comparable if I remember correctlyursus
11/20/2021, 3:59 PMRob Elliot
11/20/2021, 4:07 PMtoString
in an interface. Just have to leave it to the implementations of Id
.
Or make Id
an open class
rather than an interface.Ayfri
11/20/2021, 4:07 PMRob Elliot
11/20/2021, 4:07 PMopen class Id(
val value: String
) : Comparable<Id> {
final override fun compareTo(other: Id): Int = value.compareTo(other.value)
final override fun toString(): String = value
}
ursus
11/20/2021, 4:14 PMPaul Griffith
11/22/2021, 4:16 PMtyped IDsAn inline class? https://kotlinlang.org/docs/inline-classes.html
ursus
11/23/2021, 12:47 AM