On 10/15/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
> Hi --
>
> I'm wondering if someone could summarize for me the rationale for
> making Symbol a subclass of String in 1.9.  I understand that symbols
> and strings both represent text, and have certain characteristics in
> common, but I always thought of symbols as an internally used data
> type that Ruby exposes, essentially unchanged, for our use.  It's hard
> to adjust to thinking of them as string descendants.
>
> I guess my instinct would be to have a module -- TextLike, or
> something -- that both String and Symbol mixed in, rather than have
> Symbol be a subclass of String.

I guess that for one thing it's that there really isn't much harm in
it.  In 1.9 Symbols seem to act as frozen strings. You can't mutate
them but otherwise they act as strings.

And it's pretty common to convert between strings and symbols either
way. Rails seems to do it a lot, and it does things to make them
interchangeable in a lot of contexts.

The one thing the change does is to obsolete old explanations about
how Symbols aren't strings.  In 1.9 they ARE strings, but they are
frozen and have a fixed mapping between a given string value and the
object_id.


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/