implement inequality symbols for a custom class in kotlin
I have this class:
class Dog(private val name: T, private val weight: T): Comparable {
override fun compareTo(other: Dog): Int {
TODO("Not yet implemented")
}
override fun equals(other: Any?): Boolean {
return (other is Dog) && (other.weight == weight)
}
}
and I want to compare any two dogs based on their weights, not names like this:
fun main() {
val dog1 = Dog("Dog1", 10)
val dog2 = Dog("Dog2", 11)
println(dog1 > dog2)
println(dog1