October 2018
Intermediate to advanced
370 pages
9h 15m
English
The set function takes two parameters: an index of the array and a value to be assigned at that index:
intArray.set(2,3)intArray[3] = 4intArray.set(4,5)
Take a look at the following example:
fun declareAndInitArray(){ var intArray = IntArray(5) intArray[0] = 10 intArray[1] = 20 intArray.set(2,30) intArray.set(3,40) for (element in intArray){ println(element) } }
The set function takes the 2 index with a value of 30 and the 3 index with a value of 40 to initialize the array.
Read now
Unlock full access