Swapping two numbers is one of the most common things you do in programming. Most of the approaches are quite similar in nature: Either you do it using a third variable or using pointers.
In Java, we don't have pointers, so mostly we rely on a third variable.
You can obviously use something as mentioned here, which is just the Kotlin version of Java code:
var a = 1
var b = 2
run { val temp = a; a = b; b = temp }
println(a) // print 2
println(b) // print 1
However, in Kotlin, there is a very quick and intuitive way of doing it. Let's see how!