17 lines
266 B
Kotlin
17 lines
266 B
Kotlin
|
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
|
||
|
*/
|