January 2018
Intermediate to advanced
434 pages
14h 1m
English
In Kotlin, we have a special function, also, that we can use to swap two numbers. Here's the code to go with it:
var a = 1var b = 2a = b.also { b = a }println(a) // print 2println(b) // print 1
We were able to achieve the same thing without using any third variable.
Read now
Unlock full access