From: Stefano Crocco Date: 2007-05-29T20:44:07+09:00 Subject: Re: operator => Alle marted� 29 maggio 2007, Gian Holland ha scritto: > Hi I have a beginner question > > What does the => operator do? > > here is the example code from the book > > class Product < ActiveRecord::Base > has_many :orders, :through *=>* :line_items > #... => is not an operator, its simply the syntax used to create hashes: h = {:a => 1, :b=>2} creates an hash with keys :a and :b, corresponding to values 1 and 2 respectively. When you need to pass an hash as the last argument of a method, ruby allows you to omit the braces, so your call to has many means: has_many( :orders, {:through => :line_items} ) In other words, you're passing two arguments to the method has_many: the first is the Symbol :orders; the second is a Hash with one key (:through) and one value (:line_items) Stefano