Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the problem there is more one of library design than specifically a mutable object problem.

If `a` is mutated by the `.add()` method, then it should probably return void rather than returning a copy of the object.

Is the immutable DX still better in this specific example? Probably. But the above at least would help developers avoid the major footgun with mutability.



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: