From: Harry Ohlsen Date: 2004-03-31T09:33:12+09:00 Subject: Re: How are Symbol objects used Daniel Sheppard wrote: > It appears to me that everywhere that you could use a symbol, you could > just as easily use a string. Is there any reason other than aesthetics > that you shouldn't just use Strings everywhere? Are Symbols just a > hangover from an older Ruby version. A couple of reasons are ... 1. A symbol with a given name is unique. So, if you refer to :hello at 10 places in your code they will all be references to the same object. However, if you had "hello" in those 10 places, you'd have 10 different copies of the string "hello". In practice, this probably isn't a big deal. 2. Comparison of symbols is very cheap, since it can just compare the object references, rather than having to compare each character of two strings. I'm sure there are all sorts of other good reasons, too. Cheers, Harry O.