KotlinStudy/src/main/kotlin/Demo1/SetGet.kt

17 lines
266 B
Kotlin
Raw Permalink Normal View History

2022-05-11 17:36:48 +08:00
package Demo1
class SetGet {
var index:Int=0
get() { return field+10}
set(value) {
field = (value * 10)
}
}
fun main(args: Array<String>) {
val tmp=SetGet()
tmp.index=10
println(tmp.index)
}
/** out **
* 110
*/