Mega Code Archive

 
Categories / Ruby / Language Basics
 

Symbols is placeholders for identifiers and strings

# You can recognize symbols because they are always prefixed by a colon (:). # You don't directly create a symbol by assigning a value to it.  # You create a symbol by calling the to_sym or intern methods on a string or by assigning a symbol to a symbol.  name = "myValue" name.to_sym # => :myValue :myValue.id2name # => "myValue" name == :myValue.id2name # => true