From: cypher.dp@... Date: 2007-07-21T20:39:44+09:00 Subject: Re: Symbols You're not the first one who's asking... http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/7e9a4d1cb55d1c1f/e495f6051aebe0ae?lnk=gst&q=symbols+strings&rnum=3#e495f6051aebe0ae Hope it helps Dominik 2007/7/19, Joel VanderWerf : > Stephen Cox wrote: > > yeah I figured out symbols were the actual value. But one question, if a > > symbol is no longer used what happens to it? Is it released when the > > procedure it was create in completes? > > No. Symbols accumulate forever. They cannot be garbage collected in > current ruby. A variable whose value is a symbol actually contains a > number, which is an index into a table, rather than the characters of > the symbol. Ruby has to ensure that, as long as the program runs, this > table entry contains the same string: > > irb(main):003:0> :a.to_i > => 14033 > irb(main):004:0> 14033.to_sym > => :a > > This is another reason to use strings for most purposes. (Also, strings > look better in YAML, especially as hash keys.) > > -- > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 > >