Swap Function in Kotlin -


is there better way write generic swap function in kotlin other java way described in how write basic swap function in java.

is there kotlin language feature can make generic swap function more concise , intuitive?

no need swap function in kotlin @ all. can use existing also function, example:

var = 1 var b = 2  = b.also { b = }  println(a) // print 2 println(b) // print 1 

Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -