instance initializer
John Rose
john.r.rose at oracle.com
Fri Sep 6 00:43:14 UTC 2019
On Sep 5, 2019, at 4:47 PM, Vicente Romero <vicente.romero at oracle.com> wrote:
>
> right I was thinking about the case:
>
> record R(int i, int j) {
> public R { // compact constructor
> if (i < 0) {
> this.i = -i;
> } else {
> this.j = j;
> }
> }
> }
Correct me if I’m wrong, but we can cover cases like this by assigning to the component parameters, and let the fields get written automatically:
record R(int i, int j) {
public R { // compact constructor
if (i < 0) {
i = -i; // not this.i
} else {
j = i+j; // not this.j
}
}
}
More information about the amber-spec-experts
mailing list