Symbols vs strings vs?

Lähettäjä: Joe Van Dyk <joevandyk@gmail.com>
Aihe: Re: symbols vs strings vs ?

>
> Joe Van Dyk wrote:
> > Any rules or guidelines on when to use symbols vs strings? I'm not
> > sure as to the advantages of using symbols.
>
> Symbols are immutable strings. Every occurence of the same symbol
> correspondes to the same single object, while every occurence of the
> same string is a different object (with the same value). Thus symbols
> are a bit faster and cheaper to use in things like case statements,
> hash keys etc.
> It's also usually a bit nicer to read in the code, as it signifies that
> what you're looking it at is a unique identifier, rather than something
> that can have a dynamic content.
>
> HTH,
> Assaph

It did help! Thanks.

Always use a Symbol rather than a String, except if you
need to be able to print the string to file/screen/etc.

E

···

On Thu, 3 Feb 2005 09:35:41 +0900, Assaph Mehr <assaph@gmail.com> wrote:

Hmm, don't think I agree with that. What it you need to modify its contents? What if you want to use some of String's many helper methods?

James Edward Gray II

···

On Feb 2, 2005, at 7:53 PM, E S wrote:

Always use a Symbol rather than a String, except if you
need to be able to print the string to file/screen/etc.