what you’ve done in this case is have a variable that holds and points back to the symbol. in a sense that variable is a symbol but the symbol it refers to had to be created with the normal Ruby syntax. here’s a good link that might help you understand all that complexities of how symbols work in Ruby: http://www.troubleshooters.com/codecorn/ruby/symbols.htm Beware it’s a long read.
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.
I think my understanding is correct and inline with the link you
gave. However the link's author did make some important points:
1. Besides the Symbol class, other classes in Ruby such as Fixnum,
NilClass, TrueClass and FalseClass "ensure that if ‘two’ of their
instances are equal they are the same object."
2. Ruby's freeze method makes a particular instance immutable; adding
"Beware, though, that this only freezes the object itself and not it’s
sub-objects, or referenced objects"