October 2018
Intermediate to advanced
370 pages
9h 15m
English
When assigning one array to another, Kotlin does not create a new copy in memory. Instead, both instances of the array point to the same location. When the source array is assigned to the target array, both arrays will be impacted if either is updated. To understand this problem, take a look at the following example:
fun arrayInstance01(){ val source = intArrayOf(1,2,3) val target = source // print target for (element in target){ println(element) } // ...Read now
Unlock full access