I see colons used two different ways in Ruby
:controller => 'pages'
and then
action: => 'home'
I found an explanation here: http://goo.gl/ZKxKVK it seems that the position doesn't matter, could someone clarify this?
I see colons used two different ways in Ruby
:controller => 'pages'
and then
action: => 'home'
I found an explanation here: http://goo.gl/ZKxKVK it seems that the position doesn't matter, could someone clarify this?
action: => 'home'
is not valid syntax.
It should be action: 'home'
or :action => 'home'
.
These are equivalent. They generate:
{:action=>'home'}
Mostly it doesn't matter. Since Ruby 1.9 we can use more short form:
h = { a: 1, b: 2}
But there are some situations where you have to use the longest form, e.g.:
h = {1 => 'a', 2 => 'b'}
h = {"One Two" => 1}