Overriding equals in Kotlin
I'm learning Kotlin by reworking a small compiler I wrote in Java. CS implements kotlin.CharSequence. The essence of it is here:
class CS (val sequence: CharSequence = "") : CharSequence {
... override get/length in interface CharSequence
override fun equals(other: Any?): Boolean =
(this === other) || ((other is String) && this.sequence.equals(other))
}
The compiler objects to CS("hello") == "hello" as: Operator '==' cannot be applied to 'CS' and 'String'. It has no...