On Thursday 05 January 2006 03:13 am, Chad Perrin wrote:
> On Thu, Jan 05, 2006 at 04:25:31PM +0900, Dave Howell wrote:
> > So Steve, or anybody, I've learned that I can :mysymbol.to_i and I get
> > an integer back. OK, I give up. What possible use do I have for this
> > zany parlor trick? I'll hazard a guess that, as a "normal" programmer,
> > not doing system-level stuff, not extending Ruby, not trying to do
> > something dense and clever and incomprehensible...I don't.
>
> The integer value can be regarded as a side effect of the way symbols
> are managed.  They're stored as values in a hash table with the integers
> as keys, basically.  It's the atomic number-like value of the symbol,
> and the "it has always been there" behavior[1] of it when first defined,
> that the language feature is after -- not the integers associated with
> symbols in the hash table.  If you find a good use for the .to_i
> behavior, though, have at it.
>
> At least, that's my understanding.

Internals question: Curious -- why don't they hash with the object id instead?

SteveT
 
Steve Litt
http://www.troubleshooters.com
slitt / troubleshooters.com