Where can I find an explanation of what the => operator means in Ruby?
For example,
class Acct < ActiveRecord::Base validates_confirmation_of :password, :email_address, :on => :create end
what is the => operator doing in this case?
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 symbol ‘=>’ is not an operator. It’s just a syntactic means to express that there is a relationship of ‘key-value’ between the other two elements. It’s used to define hashes (or associative arrays, as they’re called in some other languages, eg. PHP). In this sense, because ‘=>’ it’s not an operator, it doesn’t do anything (so as symbols ‘[‘ and ‘]’ don’t do anything when used to define an array). If you are still confused, have a look into the Hash Ruby class and compare it to the Array class.