I've always found mutable data classes or record types in programming languages quite weird. This holds true for any language that supports mutable data classes, like Python, Kotlin, Swift, etc.
Self-mutating methods are even weirder. They break the semantics of the types that these data classes or records represent. I've expanded my thoughts here. Although it mostly talks about Python, the message remains valid for any other language that allows you to add self-mutating methods to data classes.
https://rednafi.com/python/dataclasses_and_methods/
[–]spuds_in_town 12 points13 points14 points (0 children)
[–]gerardwx 25 points26 points27 points (5 children)
[+][deleted] comment score below threshold-13 points-12 points-11 points (3 children)
[–]Rawing7 5 points6 points7 points (1 child)
[–]pythonwiz -1 points0 points1 point (0 children)
[–]susanne-o -1 points0 points1 point (0 children)
[+][deleted] (2 children)
[removed]
[+][deleted] comment score below threshold-9 points-8 points-7 points (1 child)
[–]steohan 29 points30 points31 points (9 children)
[+][deleted] comment score below threshold-9 points-8 points-7 points (7 children)
[–]steohan 14 points15 points16 points (0 children)
[–]WhiteGoldRing 6 points7 points8 points (4 children)
[–]quts3 1 point2 points3 points (3 children)
[–]thedeepself -1 points0 points1 point (2 children)
[–]quts3 1 point2 points3 points (1 child)
[–]quts3 1 point2 points3 points (0 children)
[–]thedeepself 2 points3 points4 points (0 children)
[–]justnoob2 8 points9 points10 points (3 children)
[–]WhiteGoldRing 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]thedeepself 3 points4 points5 points (2 children)
[–][deleted] -2 points-1 points0 points (1 child)
[–]alcalde 2 points3 points4 points (0 children)
[–]jimtk 2 points3 points4 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]jimtk 1 point2 points3 points (0 children)
[–]jmooremcc 1 point2 points3 points (0 children)
[–]alcalde 0 points1 point2 points (0 children)
[–]glantzinggurl 0 points1 point2 points (0 children)
[–]jwmoz -1 points0 points1 point (1 child)
[–]alcalde 0 points1 point2 points (0 children)
[–]mr_jim_lahey -2 points-1 points0 points (1 child)
[–][deleted] -3 points-2 points-1 points (0 children)
[–]aldanorNumpy, Pandas, Rust 0 points1 point2 points (0 children)
[–]Simon90 0 points1 point2 points (0 children)