scala BeanProperty 自动生成 getter 和 setter

当将scala字段标准为@BeanProperty时,会自动生成get/set方法。

例如代码如下:

 

import scala.reflect.BeanProperty

class Counter_3 {

  @BeanProperty

  var name: String = "hello"

}

object Counter_3 {

  def main(args: Array[String]) {

    var counter_3 = new Counter_3

    counter_3.setName("chen")

    print(counter_3.getName)

    counter_3.name

    println()

    counter_3.name = "skdkd"

    counter_3.name_= ("sdsd")

    println(counter_3.name)

  }

}

 

上一篇:Vuex之store仓库计算属性Getter


下一篇:关于 flutter本地化问题 The getter 'pasteButtonLabel' was called on null