Question about records and overriding their "magic methods"
David Alayachew
davidalayachew at gmail.com
Thu Sep 21 17:00:17 UTC 2023
Hello Amber Dev Team,
Let's say I have a record like the following.
record ComplexRecord(int blah /* and many more components */) {}
Next, let's say that I want to override my toString, to include some
derived information.
Obviously, putting the derived info into the toString is easy, but how do I
go about INCLUDING it with my original implementation of toString that was
magically created for me by Java?
If I try to fully recreate my toString, I run the risk of it becoming
out-of-date upon refactor. Best I can come up with is nesting another
record with the toString overloaded. Also not ideal.
Thank you for your time!
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230921/b5578fc5/attachment.htm>
More information about the amber-dev
mailing list