[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: symbols vs strings vs ?

e

2/3/2005 2:50:00 AM

> Lähettäjä: James Edward Gray II <james@grayproductions.net>
> Aihe: Re: symbols vs strings vs ?
>
> 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.
>
> 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?

The way I thought of it is that if you need to modify a string,
it's a string that is going to displayed somehow at some point.

For the sake of disambiguity, however, let's amend that to
"Always use a Symbol rather than a constant String..."

> James Edward Gray II

E



4 Answers

dblack

2/3/2005 4:02:00 AM

0

dblack

2/3/2005 4:12:00 AM

0

Jim Weirich

2/3/2005 4:22:00 AM

0

On Wednesday 02 February 2005 11:11 pm, David A. Black wrote:

> I'm still not convinced that there's any reason to favor having such
> things be symbols.

My rule of thumb:

* Use strings when content matters
* Use symbols when identity matters.

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)


Austin Ziegler

2/3/2005 3:44:00 PM

0

On Thu, 3 Feb 2005 13:22:24 +0900, Jim Weirich <jim@weirichhouse.org> wrote:
> On Wednesday 02 February 2005 11:11 pm, David A. Black wrote:
>
> > I'm still not convinced that there's any reason to favor having such
> > things be symbols.
>
> My rule of thumb:
>
> * Use strings when content matters
> * Use symbols when identity matters.

...and that matches mine, too.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca