Is there a convention for the use of => or : in Ruby 1.9+? like:
:param => "foo"
or
param: "foo"
EDIT: Thanks for the feedback, I edited the question to make it more clear.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a difference; The newer “JSON” style of hash creation can only be used with symbol keys. Demonstrated below.
is equivalent to
So you cannot use it to create this hash:
Or this one:
This makes a lot of sense, since it is best practice to use symbol keys when you can.
Edit:
Also in your example,
{ param => "foo" }the value of the variable param will be used as the key.so
is equivalent to