The entries of lists are mutable and can be changed freely, using indices and the index operator []:
The index operator [] takes an index and a value and changes the element placed at that index with the argument value:
val numbers = mutableListOf(50, 40, 30)
numbers[0] = 15
numbers[2] = -1
// numbers is now [15, 40, -1]
Assignment
Follow the Coding Tutorial and let's play with some arrays.
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
