What is the difference between var and val in Kotlin?
In your code result is not changing, its var properties are changing. Refer comments below: fun copyAddress(address: Address): Address { val result = Address() // result is read only result.name = address.name // but not their properties. result.street = address.street // … return result } val is same as the final modifier in java. As … Read more