4 ms·
If you are familar with Java: Just imagine all integers are objects from class Integer and that int doesn't exist. (Internally, they are actually represented a
by tralarpa 8y ago
If you are familar with Java: Just imagine all integers are objects from class Integer and that int doesn't exist.
(Internally, they are actually represented as 31-bit numbers for performance reasons)
- jhbadger 8y agoOr non-hypothetically, integers in Ruby -- 5.methods shows that 5 is an object just like anything else. But then Ruby has been called a modern Smalltalk for this reason.
- pjmlp 8y agoWith the difference that cruffy Smalltalk still has better JITs available.
- tigershark 8y agoWhy do they lose one bit?
- philippeback 8y agoBecause that bit indicates if it is a normal object or an integer (for 32 bit VM)
- philippeback 8y agoOn the 64 bit VM, we can do better now on the integer front. Floats are also boxed automagically in a 64-bit entry.