Answers for "kotlin extension function"

1

kotlin extension function

fun Int.increment(): Int {
    return this+1
}
fun Boolean.invert(): Boolean {
    return xor(true) // a xor true = !a, by the conditional inversion property of xor.
}
Posted by: Guest on July-27-2021

Browse Popular Code Answers by Language