So while in the #RubyOnRails IRC channel late at night (never a good idea) some silly conversation occured:
(someone gists some code)
sevenseacat: empty array seems the silly thing to have
Tarential: sometimes I like to add empty arrays, you know, just in case I need them later
Tarential: so they’re close at hand
tagrudev: little kittens die when you define an unused var
brianpWins: but if you do want to leave empty arrays around.
At a first glance the 1.9 ruby hash syntax looks like a simple change. No longer using the infamous “Hashrocket” and moving to a familiar JavaScript Object Notation.
{:cat => 'meow'} # 1.8 {cat: 'meow'} # 1.9 On an average day I write equally as much JavaScript as I do Ruby so the new 1.9 syntax is an easy swtich for me.
Do these updates to the syntax mean that we’ll be seeing the demise of the 1.
This is just a quick bit that I learned early in my Ruby career and always found interesting.
Symbols Are Memory Leaks
So is this the end of the world?
No
Symbols are a unique thing in ruby. It’s immutable, constant and unique. You can re-use the same Symbol over and over without allocating extra memory. As opposed to using a String over and over which will allocate memory with each instance.