Hi --

On Sat, 29 Jul 2006, nothinghappens / mchsi.com wrote:

> Sorry if anyone's beat me to this, I find it hard to keep up with
> such a busy list...
>
> : is used to denote a symbol.  The idea of a symbol has a rather
> broad interpretation, but I think that technically any identifier
> you make in a program -- a variable name or function name, for
> instance -- is a symbol.
>
> Lisp languages have symbols in a similar sense that Ruby does, and
> they are usually used in much the same capacity as variable names --
> they get evaluated into any binding they currently have to a
> function or piece of data.  However, if quoted with a single quote
> (like 'this) they are left unevaulated and treated as the symbols
> themselves.

Ruby symbols aren't exactly used as variable names, though.  If you
assign to a variable:

    a = 1

then Ruby creates and stores an :a symbol.  But if you use the symbol
:a, like this:

   b = :a

there's no direct semantic connection to your variable called 'a'.

The way I usually think of it is: Symbols, like integers, are used
internally by Ruby.  Also like integers, symbols are made available
for our use.  But if the integer 3 is used somewhere in the
interpreter, and I use the integer 3 in a program, there's no direct
connection.  The same is true of a symbol, such as :a.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.