From: Gregory Brown Date: 2006-01-02T09:18:40+09:00 Subject: Re: What is the difference between :foo and "foo" ? On 1/1/06, dblack@wobblini.net wrote: > It's actually not that complex -- basically: I decided to throw up some examples for those who like examples. > a = "string" # a contains a reference to that string irb(main):007:0> a = "foo" => "foo" irb(main):008:0> b = "foo" => "foo" irb(main):009:0> c = "foo" => "foo" irb(main):010:0> a.object_id => -605890256 irb(main):011:0> b.object_id => -605898166 irb(main):012:0> c.object_id => -605912906 > a = 1 # a contains the actual (immediate) value 1 irb(main):001:0> a = 1 => 1 irb(main):002:0> b = 1 => 1 irb(main):003:0> c = 1 => 1 irb(main):004:0> a.object_id => 3 irb(main):005:0> b.object_id => 3 irb(main):006:0> c.object_id => 3 > ("string" itself is a literal string.) But keep in mind, "string" is not an immediate value. irb(main):013:0> "string".object_id => -605956386 irb(main):014:0> "string".object_id => -605962596 Symbols, OTOH, are: (Seeing as they're just named numbers :)) irb(main):015:0> :my_sym.object_id => 4073742 irb(main):016:0> :my_sym.object_id => 4073742 Hope these examples help.