When I say { :bla => 1, :bloop => 2 }, what exactly does the : do? I read somewhere about how it’s similar to a string, but somehow a symbol.
I’m not super-clear on the concept, could someone enlighten me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
:foois a symbol named “foo”. Symbols have the distinct feature that any two symbols named the same will be identical:This makes comparing two symbols really fast (since only a pointer comparison is involved, as opposed to comparing all the characters like you would in a string), plus you won’t have a zillion copies of the same symbol floating about.
Also, unlike strings, symbols are immutable.