From: Bill Kelly Date: 2002-12-03T03:30:08+09:00 Subject: Re: Symbol class for a newbie, I'm just not getting it. :-( Hi, From: > > "some_identifier" vs ":some_identifier"? > > I'm just not getting the Symbol type. What does this buy me? When would I want > to use it? What is it analogous to in another language? > > I understand how to use the colon with attr_accessor through rote memorization; > but I don't really understand it. :-( > > Can someone provide a very simple example of its proper use and advantages? Here's a recent thread on the subject... http://groups.google.com/groups?threadm=F5bQ30ITd1U4qECJ9O500008e6a%40hotmail.com&rnum=2 I personally like symbols for certain kinds of constants in my code. For ex: hat.add_relation(:synonym, "chapeau") hat.add_relation(:has_part, "brim") hat.add_relation(:kind_of, "clothing") Others have pointed out that using symbols thusly allows me to misspell my constants without Ruby catching my mistakes... But this doesn't seem to bother me. :) Hope this helps, Bill