From: Austin Ziegler Date: 2006-04-08T00:30:32+09:00 Subject: Re: what are sympbols?!? On 4/7/06, Les Nightingill wrote:> Logan Capaldo wrote:> > > Likewise in ruby:> >> > { :class => "A" }> >> > 1.send(:class)> >> > The hash key has the same name as the method being sent via send, but> > the results are different.>> I too am struggling to understand, and this statement has me even more> confused!>> How can my results be predictable if :class isn't uniquely associated> with something (hash key, or method)? Doesn't this lead to ambiguities? No. Like most people, you seem to have assumed that Symbols arespecial. They aren't. Really, there's not much difference between: { :class => "A" } and { 5 => "A" } It's the *methods* that are special. Not the Symbols. Symbols are justinvariant names. The only *really* special thing about them is thatsyntax automatically creates Symbol objects, and those Symbol objectsexist for the life of the program. That is, def foo end creates a Symbol called :foo. (If one doesn't already exist.) Similarly, class Foo end creates a Symbol called :Foo (again, if one doesn't already exist). But the real magic of a Symbol isn't in the Symbol; it's just a name.There's nothing special or magical about the name "Les Nightingill" --except that it identifies you ... and anyone else named "LesNightingill." There might be very few people named "Les Nightingill",but I know of at least three people named "Austin Ziegler" (includingmyself) and many more named "Austin". It's how you *use* the nameinvolved that makes the name special. So the magic behind #attr_acessor and #send (or #__send__) is themethod, not its Symbol argument. Sort of like "Santorum." ;) -austin--Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca