What’s the difference between colon : and fat arrow => in Ruby? Or when to use what?
:foo => true
foo: true
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.
The syntax is for defining Hash key/value pairs, and the difference depends on the Ruby version.
Supported in both Ruby 1.8 and Ruby 1.9
Supported only in Ruby 1.9
If you’re developing in Ruby 1.9 you should probably use the syntax:
as it appears to be the direction the community is moving in.