|
|
|
|
|
by fooyc
997 days ago
|
|
The author cites this to justify the need for Records: > Most Java objects set every field to be private and make all fields accessible only through accessor methods for reading and writing. > Unfortunately, there are no language enforced conventions for defining accessors; you could give the getter for foo the name getBar, and it’ll still work fine, except for the fact that it would confuse anybody trying to access bar and not `foo'. Scala supports pattern matching on objects implementing the `unapply` method. Is this considered harmful? Why didn’t Java follow this route? |
|