Swap variables with one line

PHOTO EMBED

Thu Apr 22 2021 13:25:56 GMT+0000 (Coordinated Universal Time)

Saved by @larcos #kotlin

var a = 1;
var b = 2;
    
a = b.also { b = a } // now a = 2, b = 1
content_copyCOPY

https://medium.com/swlh/kotlin-tips-tricks-you-must-know-in-2021-172700af193a