inc

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
operator fun inc(): UInt

Returns this value incremented by one.



fun main(args: Array<String>) {
//sampleStart
val a = 3
val b = a.inc()
println(a) // 3
println(b) // 4

var x = 3
val y = x++
println(x) // 4
println(y) // 3

val z = ++x
println(x) // 5
println(z) // 5
//sampleEnd
}

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-u-int/inc.html