From: Austin Ziegler Date: 2005-12-30T14:45:55+09:00 Subject: Re: What is the difference between :foo and "foo" ? On 29/12/05, Devin Mullins wrote: > Austin Ziegler wrote: > >The Symbol is just a name. > Er... a thing that /has/ a name. (That being, Symbol#to_s.) No, I think that the essential property of a Symbol is that it is an object that is a name: keep = Symbol.all_symbols quuxl = nil puts Symbol.all_symbols - keep You'll see that :quuxl is there. You can get a string representation of that name (:quuxl.to_s) or an integer representation of that name (:quuxl.to_i), but the canonical representation of that name is the Symbol itself (:quuxl). Sure, you could get pedantically philosophical, but the you'd be saying that 1 really isn't the number, it's a thing that represents a quantity of one. For all practical purposes, Symbols are atomic in the sense that they are themselves. Who *cares* how it's actually represented in the implementation? That can change. The fundamental nature of a Symbol is that :quuxl will always be :quuxl and never anything else. Consider these two IRB sessions: irb(main):001:0> :bar.to_i => 23417 irb(main):002:0> :quuxl.to_i => 23425 irb(main):003:0> irb(main):001:0> :quuxl.to_i => 23417 irb(main):002:0> :bar.to_i => 23425 irb(main):003:0> A Symbol, like a number, is immediate and is identified by itself. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca