https://kotlinlang.org logo
Title
u

user

07/13/2022, 5:31 AM
Comapring data class in Kotlin using == operator I am trying to write an assertion by comparing two Kotlin data classes.I am just simplifying the question by using a minimal class. data class X(val isThatSo: Boolean) { val name:String = "xyz" } In my test val s = """ { "isThatSo": "true", "name": "Ankit" } """ assert(Gson().fromJson(s, X::class.java) == X(true)) Looks to me that the name field is not compared at all because the value in both the objects is different. Is my understanding correct?