From: "Marcin Mielżyński" Date: 2006-11-10T08:25:07+09:00 Subject: Re: Overwriting the Integer class for method succ! (instead of just succ) paul wrote: > Now I still wonder, the only source-code I found for the Integer class > was in C. From this I wasn't able to figure out how I would go IF i'd > like to write this count++ (and with that modifying all 1's to 2's > e.g.). > > This kind of information, is not in the Programming Ruby Built-in > Classes and Methods chapter. Is this because that only contains the > public methods, and not the protected's? Or are there no such thing as > protected's for Integer (because it's in C?)? > > Cheers again > Nope, since Fixnum is an immediate value (variables are copied - not the values they refer to) and there is only one instance of a specific number (so only one 1, 2, 3 etc...). Changing it would affect all other instances in the whole interpreter (in fact a single Fixnum instance takes only 4/8 bytes depending on the architecture - so they cant have a singleton). But it is possible to tweak Float instances ;) , although they are (seem to be) immutable, but not immediate (only on the c side - but quite easy). lopex