Reputation: 12366
I added my own getter and setter to a variable:
class Person{
private var age = 0
def currentAge = age
def currentAge_=(age: Int) = this.age = age
}
Looking at compiled version gives:
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();
}
I want to avoid automatic generation of default getter and setter. Is it possible?
Upvotes: 7
Views: 426
Reputation: 67888
private[this] var age = 0
so that age
is only visible to the instance.
Upvotes: 12