我将自己的 getter 和 setter 添加到变量中:
class Person{
private var age = 0
def currentAge = age
def currentAge_=(age: Int) = this.age = age
}
查看编译版本给出:
public class Person implements scala.ScalaObject {
private int age;
private int age();
private void age_$eq(int);
public int currentAge();
public void currentAge_$eq(int);
public Person();
}
我想避免自动生成默认的 getter 和 setter。可能吗?