I was writing a rake task to handle importing data from an older community system and needed to set a default value for anything that the old system didn’t have. I was using hashs and thought to myself “It would be sweet if hashs had defaults.” After a quick doc check I found out that hashs do infact support defaults.
I encourage you to check out the Ruby Docs http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-default
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.