Hi --

On Mon, 31 Jul 2006, Charles Hoffman wrote:

> On Sun, 2006-07-30 at 17:52 +0900, Aleks Kissinger wrote:
>> As far as an analogue in other languages, I tend to think of symbols
>> sortof like old-style C defines.
>>
>> #define HAS_EGGS 1
>> #define CAN_FRY 2
>> add_property(HAS_EGGS);
>> add_property(CAN_FRY);
>
> I hadn't thought of that, but much of the typical usage is somewhat
> similar.  But Ruby's symbols can also be used to refer to an existing
> attribute or method by name... you see a lot of that sort of thing in
> _why's stuff.

True, but only if the method that uses them takes a symbol.  For
exapmle, when you do:

   obj.method(:x)

the use of the symbol for the method's name isn't what gets you access
to the method object.  In fact, most of the Ruby methods that take
symbols also take strings:

   obj.method("x")

So it depends on what a given method does with its arguments.


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.