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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With