Closed Lanchon closed 3 years ago
You're absolutely right; I misread the spec for JEP359 with regards to 'may'. (or at least, I got the precedence of ', and' wrong when interpreting the binding ;) )
Thanks, tidied.
FWIW - there has been a small and annoying change between j14 and j16; you can't assign to 'this.field' inside the non-argumented canonical constructor any more!
Special consideration is provided for explicitly declaring the canonical constructor (the one whose signature matches the record's state description). The constructor may be declared without a formal parameter list (in this case, it is assumed identical to the state description), **and** any record fields which are definitely unassigned when the constructor body completes normally are implicitly initialized from their corresponding formal parameters (this.x = x) on exit.
you can't assign to 'this.field' inside the non-argumented canonical constructor any more!
very reasonable in my eyes. you can just assign to the local parameter for similar effect. this is the way i would have designed the language myself.
thank you!
from page http://www.benf.org/other/cfr/java14record_types.html:
This won't compile in 14-ea+34-1452, complaining about potentially uninitialised firstname. This might be a javac bug?
could it be that the 'implied' argument version extends the default constructor while the explicit one replaces it?