From: Zhao Yi Date: 2008-12-18T09:55:32+09:00 Subject: Re: A question about ruby array David A. Black wrote: > It's actually hashes, not arrays, that use this syntax (see other > reply in this thread). What the :id thing means is that :id is a > Symbol object. Symbol is a class of objects that correspond directly > to entries in Ruby's internal symbol table. There's one entry for > every identifier in use while your program is running: every variable > name, method name, and constant. If you want to see them all, you can > do: > > Symbol.all_symbols > > in irb. > > The symbol table is really part of the inner workings of the > interpreter, but Ruby exposes it to programmer-space through the > Symbol class. Symbols have characters; therefore, they're used a lot > in situations where you might also use strings (such as hash keys). > They're more lightweight in terms of processing than strings are: a > string has to know how to resize itself, for example, whereas a symbol > is immutable. > > > David Ok I understand, thanks for your explanation. -- Posted via http://www.ruby-forum.com/.