From: Hal Fulton Date: 2004-09-20T13:35:07+09:00 Subject: Re: Nuby question about symbols James Britt wrote: > Hal Fulton wrote: > ... > >> >> I'd only add that one common use for a Ruby Symbol is to stand for a >> method >> name. (That's a slightly misleading statement perhaps -- attr_accessor >> takes >> one symbol and creates two methods, but their names are both based on the >> symbol.) >> >> For example, attr_accessor takes symbols, as does Object#send. > > > Why? Speed? I imagine that, in both cases, a string could have been > used as well. A string, though, would let you craft an invalid method > name. > > Maybe that's the reason for using symbols. Well, many times a string will work in place of a symbol. It depends on the method being called. Two other observations: 1. It's possible to call otherwise illegal method names via send 2. It's possible to include non-alphanumeric chars in a symbol Hal