3 ms·
Numbers are literally never immutable in any language that isn't designed intentionally for comedy. Variables of a number type may be mutable, but the numbers t
by eyelidlessness 7y ago
Numbers are literally never immutable in any language that isn't designed intentionally for comedy. Variables of a number type may be mutable, but the numbers themselves never mutate. Strings are typically immutable in most languages, but that does vary some (generally surprising people who expect primitives to be immutable).
- stellalo 7y agoFor a moment I started imagining what a mutable number would be like: > 3 = 5 > print 3 5 The end
- tralarpa 7y agoYou can kind of do that in Java by manipulating the integer cache
- mqus 7y agoPythons numbers aren't as immutable as you think ;) https://kate.io/blog/2017/08/22/weird-python-integers/ https://kate.io/blog/2017/08/22/weird-python-integers/