https://kotlinlang.org logo
d

Davor Maric

06/20/2018, 12:09 PM
Guys quick question... is data class with custom equals possible in Kotlin?
Copy code
data class AnswerViewModel(val id: Long, val title: String, val isCorrect: Boolean) {


    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is AnswerViewModel) return false

        if (id != other.id) return false

        return true
    }

    override fun hashCode(): Int {
        return id.hashCode()
    }

}