Understanding Symbols in Ruby
Its been an absolute blast so far learning RoR and Ruby. After doing much reading on Rails, I decided to try as much as I could to understad its base (Ruby) technology. So I’ve been catching up on my Ruby for the past week or so, its quite a beautiful language. Coming from PHP/MySQL programming, I have many things to “unlearn” as it were. Now I’m not a hard-core programmer by any stretch of the imagination, I love to dabble though. Also being MAJOR right brained individual, learning logistic programming used to be something of an impossibility for me, but over the years I’ve balanced myself out quite a bit through web scripting.
One of the things in Ruby I had a difficult time grasping was the concept of Symbols, (:sybmol) what they were and what they were good for. For example, from Poignants Guide to Ruby, it states:
“Symbols are words that look just like variables. Again, they may contain letters, digits or underscores. But they start with a colon. Symbols are lightweight strings. Usually, symbols are used in situations where you need a string but you won’t be printing it to the screen.”
Well thats great an all, but I still wasn’t quite sure. I did bit of searching and found an excellent post explaining it in a manner I could process easier over on glu.ttono.us.
If you’re interesting in learning symbols in Ruby from a different point of view, check it out here
- UPDATE *
I found another great article, this one meant for Ruby Newbies but explains the concept of symbols in a programming neutral manner and compares how it can be viewed from different languages. Check it out: http://www.troubleshooters.com/codecorn/ruby/symbols.htm
.
Posted on April 13, 2006
Filed Under Daily Thoughts, Ruby on Rails, Tech
Related Posts:
-
Ruby on Rails 1.1 Released!
Apple publishes Ruby on Rails tutorial
Locomotive: OS X 1-click Ruby on Rails development environment update
Ruby CGI DoS Exploit - Mongrel Hot Fix
Quote: Enlightenment
Ruby on Rails 1.1 PDF Reference
Comments
Leave a Reply
