Matter related to the old and new Ruby programmer, and Ruby’s symbols are confusing sometimes or always. Smoothly before this, can not get used is pretty. People learn about the Ruby language is often Rubionreiruzu learn from the project. The Rubionreiruzu symbol is everywhere. There really is everywhere. So, pay attention to the concept of a symbol of ruby, it’s important to remember that.
Ruby is an instance of a symbol of class symbol. Put before the identifier symbol following the colon, “: name”, “: id” or “: user”. Ruby Symbol class includes a method of a class.
- all_symbols – Returns an array of all the symbols currently in Ruby’s symbol table.
- id2name – Returns the name or string corresponding to sym:, name.id2name the “name” back.
- inspect – Literally back to the symbol.
- to_i – Return a unique integer to each symbol. This method never raises an exception.
- to_s – id2name as same. Returns the string.
- to_sym – Returns the symbol corresponding to string.