From 62fb58b0fe49d7e13e683e120ff2cb4086a85ebc Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 11 May 2022 17:36:48 +0800 Subject: [PATCH] =?UTF-8?q?set=20get=20=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/Demo1/SetGet.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/kotlin/Demo1/SetGet.kt diff --git a/src/main/kotlin/Demo1/SetGet.kt b/src/main/kotlin/Demo1/SetGet.kt new file mode 100644 index 0000000..71e2e67 --- /dev/null +++ b/src/main/kotlin/Demo1/SetGet.kt @@ -0,0 +1,17 @@ +package Demo1 + +class SetGet { + var index:Int=0 + get() { return field+10} + set(value) { + field = (value * 10) + } +} +fun main(args: Array) { + val tmp=SetGet() + tmp.index=10 + println(tmp.index) +} +/** out ** + * 110 + */ \ No newline at end of file