Tsallaka zuwa abun ciki
Justice Tech School

Lists

listOf is read only and mutableListOf can change. Use index, size, first, last and slicing.

Example
val a = listOf(10, 20, 30)
val m = mutableListOf("x")
m.add("y")
m += "z"
println("$a ${a[1]} ${a.size} ${a.last()} $m")
println(a.slice(0..1))

Exercise

Changeable list.

Of(1)

Quiz Test

Can you add to listOf?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.