3 ms·
OK, fair point. I misremembered the list interface. `set` is a better example: `set.union`, for example, returns a new set, while `set.add` updates in place. (
by colanderman 8y ago
OK, fair point. I misremembered the list interface.
`set` is a better example: `set.union`, for example, returns a new set, while `set.add` updates in place. (To be fair, this is with Python 2.7, maybe Python 3+ is more uniform?)
- acdha 8y agoWhat would you expect it to do differently in those cases? That seems like the API is following how most people would think about those operations as you'd expect in a language which isn't trying to be immutable.
- pfranz 8y agoI thought it was interesting that Ruby, by convention, used an exclamation mark to convey that a function would mutate. I haven't used Ruby all that much to see how well that works at scale.
- deleted 8y ago[deleted]
- pseudalopex 8y agoMany libraries don't use it. Another convention uses it for methods that might raise an exception.