From: dblack@... Date: 2006-01-02T08:23:51+09:00 Subject: Re: What is the difference between :foo and "foo" ? Hi -- On Sun, 1 Jan 2006, Malte Milatz wrote: > Christian Neukirchen: >> Malte Milatz: >>> My understanding of things so far was that :sym and 3 are immediate >>> values, and after writing >>> a, b = :sym, 3 >>> a is a reference to :sym and b is a reference to 3. >> In the current implementation, no. It doesn't matter to the programmer, >> though. > > I'm happy I'm not forced to dig into the details of Ruby's immediate > values... It's actually not that complex -- basically: a = "string" # a contains a reference to that string a = 1 # a contains the actual (immediate) value 1 ("string" itself is a literal string.) I think that Fixnums, Symbols, true, false, and nil are the only objects that appear in variables as immediate values. Most of the time you're dealing with references. In practical terms, it doesn't normally matter too much. You always use the same syntax for sending messages to objects through variables, whether the variable contains a reference or an immediate value. David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black