PDA

View Full Version : ruby symbols, :string (colon followed by a string literal)



cybo
September 15th, 2009, 04:43 AM
i'm trying to understand what they (ruby symbols) mean but i'm still confused. other languages call it string interning. i have programmed before but as it turns out i didn't program much. can someone explain what is the purpose of ruby symbols and how do they work?

here is an example from the book:

:Object
:my_variable
:"Ruby rules"
a = 'cat'
:'catsup' --> :catsup
:'#{a}sup' --> :catsup
:'#{a}sup' --> :"\#{a}sup"

any help is appreciated.

Ruhe
September 15th, 2009, 06:40 AM
Read: http://www.rubytips.org/2008/01/26/what-is-a-ruby-symbol-symbols-explained/

cybo
September 16th, 2009, 02:20 PM
Ruhe, thanks for the link. it helped, somewhat. if anyone knows other links to ruby symbol explanations i would appreciate it