"gabriele renzi" <surrender_it / remove.yahoo.it> schrieb im Newsbeitrag
news:ulgl60tb5mmeos6eoctd7po3sduifeqfki / 4ax.com...
> il Wed, 31 Mar 2004 14:58:20 +0200, "Robert Klemme" <bob.news / gmx.net>
> ha scritto::
>
>
> >
> >> in general, I even believe using symbols is safer than using string.
> >> If you are using a string and do not need it's features (take a look
> >> at String.instance_methods ) you may think of using a symbol (even if
> >> not everything is allowed as a symbol), avoiding possibly messing up
> >> something by changing the string.
> >
> >No, in that case you use #freeze.  You should make it only dependent on
> >the semantics and not on the methods you actually use.  It's perfectly
ok
> >to have a string constant, when it's appropriate - even if you don't
need
> >to change it.  Apart from that methods might not accept a Symbol.
>
> I agree that it's a question of semantics.
> I just believe that in most cases a simple symbol is what is needed,
> not a String.

I wouldn't judge on the relative frequency of those situations.  I just
wanted to make sure that people do not believe String and Symbol are
completely interchangable.

> I dont' want to let the user do stuff like:
>
> str='something'
> str.freeze
> ..use str

Note that you can do

str='something'.freeze

> when I can simply let him do
> .. use :something
>
>
>
> I.e, if there is the need to have some stringish key for an hash, I'd
> prefer to use a symbol over a string.

True, that's often reasonable.  Although in those cases an OpenStruct or a
Struct might be more appropriate.  It depends...

> But maybe it's just that typing "s" instead of :s is much harder on my
> keyboard :)

And it saves you a lot of typing (8 chars). :-)

Regards

    robert