October 2018
Intermediate to advanced
370 pages
9h 15m
English
The copy function helps to create an independent instance by copying the existing object. This function does not exist in the normal class, which makes it a bit inconvenient when we need a new object of an existing type. Let's create a normal class and try to create a copy of existing instance:
class Person(var name : String, var age: Int, var height: Double)val abid = Person("Abid", 40, 6.0)val khan = abid
Ideally, both abid and khan should be two separate entities, but both objects are aliases of each other and point to the same memory location:

Read now
Unlock full access