From: Austin Ziegler Date: 2005-12-30T01:30:29+09:00 Subject: Re: What is the difference between :foo and "foo" ? On 29/12/05, Steve Litt wrote: > They wouldn't exist, or they wouldn't be called symbols. If I'm referring to > an instance instead of a value, I could call it &variable as in C, or I could > call it :variable, but in that case I'd call it a reference, not a symbol. http://www.oreillynet.com/ruby/blog/2005/12/symbols_strings_methods_and_va.html When I do the following: attr_accessor :foo I am not referencing anything. I am naming something. There is no analogue between a Ruby Symbol and a C/C++ reference or pointer. Symbols name things, and they are important enough that they are intrinsic types just like Strings, Arrays, Hashes, and Integers. What makes Symbols "special" in the current implementation is that a Symbol is created for every named item. >> olds = Symbol.all_symbols; nil nil >> quuxl = 0 0 >> Symbol.all_symbols - olds [:quuxl] But as I stated in the blog entry I posted above, the Symbol is just a name. What gives a Symbol its power is the thing that uses it, such as attr_accessor. Symbols are names. No more, no less. Really, I think that people create the confusion for themselves, expecting them to be more than they are. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca