From: Devin Mullins Date: 2005-12-30T14:25:50+09:00 Subject: Re: What is the difference between :foo and "foo" ? For the heck of it, I decided to come up with my own Symbol analogy. Caveat reader: A symbol is a bubble. In Ruby-land, there is this ever-present *ether* wherein lies an abundance of bubbles. Every symbol you could ever want is out there, in the ether, bubbling along. For every name, there is a single bubble. For every bubble, there is a single name. When you assign +x = :mr_t+, as with all variable assignments, you're pointing x to the :mr_t object. Here, you're pointing at that bubble that the Ruby interpreter recognizes as :mr_t. For plausability reasons, the Ruby interpreter blows the :mr_t bubble the first time you mention its name, but for your sake, you can assume that the :mr_t bubble has always existed and always will exist -- it's just there, floating in the ether, waiting to be pointed to. So from that description right there, we already know one thing we can do with bubbles--er, Symbols--determine equality. Are these two variables pointing to the same bubble? Find me the Hash value whose associated key is this bubble I'm pointing to right now. For programming convenience, these bubbles have names associated with them, but as far as your code is concerned, they're just bubbles. This is the magic behind {:server => 'localhost', :port => 80}, etc. The other (principal) thing you can do with a bubble--eh, Symbol--is find out its name at runtime (thanks to #to_s or #id2name). Thus, attr_accessor :mcklellan is born. I'm passing along a pointer to the :mcklellan bubble. attr_accessor follows the pointer, talks to that bubble, asks it what its name is, and uses that information to define some methods. Here, :mcklellan is just used as a fancy shorthand for 'mcklellan'. (It happens to be one I like, but I digress...) So, uh, yeah. That's it. The End. Ha, yeah, so that description is probably more unsettling than settling, but maybe it'll plant a seed of wisdom, or whatnot. Plus, I can rest easy, now that I've solved everybody's problems. Devin Did I really just digress into "The End"?