rubysyntaxhashrocket

Notation "name: " vs ":name => "


I'm not too clear what's the difference between the follwing two notations:

= render :partial => "order_fields", :locals => { :t => type, :f => c}
= render :partial => "order_fields", :locals => { t: type, f: c}

They both seem to work but I can't understand what's the difference. Could you please help me?


Solution

  • No difference. The latter is a new hash syntax in ruby 1.9.

    (Why do I still call this "new syntax"? Ruby 1.9 is 4 years old, and it's not even the current version :))