On Fri, Feb 17, 2012 at 4:10 AM, Ronnie Collinson <notthinking / gmail.com> wrote: > Symbols currently have the nice property of being guaranteed (at least > I hope this is right) of always being the same object (due to being > immutable), Well, their Symbol state is immutable but you can nevertheless change them: irb(main):001:0> s = :foo => :foo irb(main):002:0> s.frozen? => false irb(main):003:0> s.instance_variables => [] irb(main):004:0> s.instance_variable_set '@x', 123 => 123 irb(main):005:0> s.instance_variable_get '@x' => 123 irb(main):006:0> s.instance_variables => [:@x] irb(main):007:0> :foo.instance_variables => [:@x] > allowing a simple comparison of address to see if there > equal and using very little memory. Actually I don't think there is much memory saving compared to String. > Aren't symbols also kept separate > to the main heap, which the gc owns/runs? Matz said: M> In 1.9, symbol names are stored as Ruby strings, so that they have to M> be marked to avoid reclaiming. So they are not kept separate in 1.9.*. > Other then space, what could be gained from gcing symbols. Space is the only thing that can be gained from GCint _any_ object. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/