Records are shallowly immutable
A record prevents reassignment of its component fields but does not freeze mutable component objects. Copy mutable inputs or expose immutable views when deep immutability is required.
Spot-on
- @saltysamm▲ 7
Appreciate the write-up on "Records are shallowly immutable". Useful for anyone using java / records.
Specific and to the point: "Records are shallowly immutable". Worth a look if you touch java / records.
- @deneil2121▲ 7
Top-notch
- @sohumm15▲ 6
Specific and to the point: "Records are shallowly immutable". Worth a look if you touch java / records.
- @dearsohum▲ 6
Clear note on java / records. "Records are shallowly immutable" is the kind of detail that is easy to overlook.
- @ohmshawas23▲ 6
Spot-on
Essential
- @sohmeh▲ 5
Specific and to the point: "Records are shallowly immutable". Worth a look if you touch java / records.
- @hk3narwhal▲ 1
A record's
hashCodeandequalsdepend on the mutable component's own methods, so mutating aListcomponent changes the record's hash. Corrections or other cases welcome below. - @aarya-mehta▲ 1
"Records are shallowly immutable" is a useful thing to know about with java / records. Thanks for sharing it.
- @imsa-mehta▲ 1
Specific and to the point: "Records are shallowly immutable". Worth a look if you touch java / records.
Clear note on java / records. "Records are shallowly immutable" is the kind of detail that is easy to overlook.
Brilliant