<div dir="ltr">Hi,<div><br></div><div>JEP-468 briefly mentions that derived record expressions can also be used inside the record class:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Derived record creation expressions can also be used inside record classes to simplify the implementation of basic operations:  </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">record Complex(double re, double im) {<br>    Complex conjugate() { return this with { im = -im; }; }<br>    Complex realOnly()  { return this with { im = 0; }; }<br>    Complex imOnly()    { return this with { re = 0; }; }<br>}</blockquote><div><br></div><div>I'm trying to understand what happens when a derived expression is used in a record method taking a parameter with the same name as one of the record components:</div><div><br></div><div>record Complex(double re, double im) {<br>    Complex withReal(double re) { return this with { re = ?; }; }<br>}<br></div><div><br></div><div>Can "this" be used inside the transformation block, like the following?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">     Complex withReal(double re) { return this with { <a href="http://this.re">this.re</a> = re; }; }</blockquote><div><br></div><div>I know this particular example is a bit silly, but I think it may be useful to combine multiple transformations in a single record method, also when the method takes one or more parameters. People will be running into this.</div><div><br></div><div>Perhaps this could be clarified in the JEP with an example or does it need clarification in the JLS? Or is it just me missing something, as usual? :-)</div><div><br></div><div>Thanks,</div><div>Eirik.</div><div> </div></div></div>