On Jul 15, 8:29 pm, Bryan Ash <[email protected]> wrote:

> They have the same object_id because they're pointing at the same
> object.

Agreed.

I was trying to demonstrate that a variable, say the unassuming x,
could actually turn out to be a Symbol (even though it is not prefixed
with a colon).  However, that is not surprising because:

1.  In Ruby one can write

x = :my_symbol

but can't write

:my_symbol = x  # This is sort of equivalent to trying to write 5 = x

That is, apart from specifying a Symbol literally (e.g. :my_symbol)
one can only specify a Symbol by specifying the variable that
references it.  Like ALL objects in Ruby, to specify the object you
either specify it literally or specify the variable that references
it.

2.  Since Ruby is a dynamically typed language a variable, say the
unassuming x again, can reference different classes of objects
throughout a program.  As such, a variable could reference any class
of object at a particular moment in time, including a Symbol object.

Apologies if this is not a revelation to the reader.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to