copy and equals
Generated functions.
Generated Functions
Beyond toString, a data class generates equals, hashCode, and copy.
These three make data classes a joy to compare and clone.
Structural Equality
The generated equals compares objects by their property values, not their identity.
Two data class instances with the same values are equal with ==.
data class User(val name: String, val age: Int)
fun main() {
val a = User("Alice", 30)
val b = User("Alice", 30)
println(a == b)
}