Hey! Is it possible to swap two elements in a muta...
# announcements
k
Hey! Is it possible to swap two elements in a mutableList? Can’t find any swap method.
g
Copy code
val m = mutableListOf<Int>(1,2,3)
    m.set(0,2)
    m.set(1,1)
    println(m)
there is no swap method. you can write extension method.
d
If you're on JVM, you could use
Collections.swap