actually, this works just fine: {"symbol-key-with-dash": :cool}. its that you can write a Symbol literal with quotes: :"looks-weird-still-is-symbol"
as a newcomer, my first "whoa" effect was when i realized that every function call like render :show, status: :created, location: @user is ultimately translated to: render(:show, {:status => :created, :location => @user});. it's just that in ruby you don't have to specify that curly braces to make the last argument a Hash. ruby is implicit. you can omit the brackets, the semicolon.
Oh interesting! Didn't know that. I personally think it's a bit confusing to have do "string": or :"string"if you wanted to have a key as a String instead of a Symbol. Good point to bring up though.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
just doing a nitpick addition :-) :
actually, this works just fine:
{"symbol-key-with-dash": :cool}
. its that you can write a Symbol literal with quotes::"looks-weird-still-is-symbol"
as a newcomer, my first "whoa" effect was when i realized that every function call like
render :show, status: :created, location: @user
is ultimately translated to:render(:show, {:status => :created, :location => @user});
. it's just that in ruby you don't have to specify that curly braces to make the last argument a Hash. ruby is implicit. you can omit the brackets, the semicolon.Oh interesting! Didn't know that. I personally think it's a bit confusing to have do
"string":
or:"string"
if you wanted to have a key as a String instead of a Symbol. Good point to bring up though.