Possible Duplicate:
Is there any difference between:key => "value"andkey: "value"assignments?
key in ruby new hash
I am reading some rails code and I see a method can be called
foo(:var1 => 'hello', :var2 => 'world')
or
foo(var1: 'hello', var2: 'world')
Both seems to work exactly the same. Is there any difference? Which is the better practice?
They mean the same thing. The latter is new Ruby 1.9 syntax inspired by JavaScript. Use the former if you need to stay compatible with Ruby 1.8. Otherwise it’s a matter of taste.