From: Jeremy Bopp Date: 2012-06-21T07:06:27+09:00 Subject: Re: Symbols and Strings... On 06/20/2012 03:58 PM, Henry Maddocks wrote: > > On 21/06/2012, at 8:50 AM, Bartosz Dziewoński wrote: >> Symbol is just that – a symbol. Internally it is stored as a *number* >> and in C code passed by-value, like Fixnum, instead of by-ref, like >> all other objects. It is only shown as a bit of text for display. > > The internal representation is of no concern to the programmer, only it's utility. > There seems to be a desire to be able to use String and Symbol interchangeably, hence this discussion. Given that Strings and Symbols are different entities (as has been discussed at length here and other places), it's not possible to expect them to be interchangeable in *all* cases. This even holds true if one class inherits from the other. After all, the point of descending one class from another is to make something related but at least a little different. Therefore, interchangeability must be limited to some extent as long as Symbol and String are different things. So then, in what cases would it be helpful to use them interchangeably? Is it possible to define a common, useful interface that both Symbol and String could implement. If so, perhaps a class or module could be defined for that interface and incorporated into both classes as appropriate. From what I've seen, the most frequently voiced desire is to be able to use apparently equivalent symbols and strings as fully equivalent hash keys. What else is there? -Jeremy