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
Post a Comment