/* * When you pass an object in Kotlin, you can change the internals of the * object. But you still cannot change the thing pointed to * * @author gtowell * created: August, 2021 */ data class DCls(var a:Int, var b:Int) fun main() { var aa : DCls = DCls(1,2) println("MAINa: ${aa} ${System.identityHashCode(aa)}") pass(aa) println("MAINb: ${aa} ${System.identityHashCode(aa)}") aa = DCls(4,16) println("MAINc: ${aa} ${System.identityHashCode(aa)}") } fun pass(pss: DCls) { println("PASSa: ${pss} ${System.identityHashCode(pss)}") pss.a=5 println("PASSb: ${pss} ${System.identityHashCode(pss)}") }