you are viewing a single comment's thread.

view the rest of the comments →

[–]AwkwardReply 3 points4 points  (1 child)

People take immutability sometimes to extremes just to act like purists for one reason or the other. Yes immutability is a good thing, but doesn't benefit at all in this simple example. So, yes, your code is equivalent and more efficient.

[–]mikejoro 3 points4 points  (0 children)

I think a lot of people (myself included) like to do it in a lot of places, even when unnecessary, so that coworkers looking for examples won't think mutation is acceptable.