From: Yossef Mendelssohn Date: 2008-11-27T01:47:54+09:00 Subject: Re: Class setter On Nov 26, 10:43 am, Ves Pasian wrote: > For the life of me I can figure out why the setter below returns "v" and > not nil > > class A >   def initialize(id) >     @id = id >   end > >   def id >     @id >   end > >    def id=(v) >      nil >    end > end > > a = A.new(1) > a.id = 2 > => 2 That's just the way setters work in Ruby. Any method ending in = will return what you pass to it. That way, it's analogous to setting regular variables, like x = y = z. On a similar note, though you "configure" the class method .new with the instance method #initialize, you can't make .new return something other than an instance of the class just by the return value of #initialize. -- -yossef