← Coding round practice

Swap Two Numbers

EasyNumbers & Math

The problem

Swap the values of two variables.

Sample input

a = 5, b = 10

Sample output

10 5
Show the solution · 8 languages
fun main() {
    var a = 5
    var b = 10
    a = b.also { b = a }
    println("$a $b")
}