From: Robert Klemme Date: 2012-05-11T19:55:08+09:00 Subject: Re: passing via instance variable or regular () On Fri, May 11, 2012 at 12:32 PM, sam jam wrote: > "for a > method there exists an additional precondition (i.e. that some > instance variables are set in a particular way)." > > there is still a precondition in either case > > precondition: an instance variable is set in a particular way > > >  def first >    @name = "sam" >    last >  end > >   def last >     name = @name + " " + "jam" >   end > > > precondition: something is passed to it (something set in a particular > way) > > > def first >    name = "sam" >    last(name) >  end > >   def last(first) >     name = first + " " + "jam" >   end > > > A lot of what you said I see as great points, but not that one because > it is the same in either case. But the precondition of having a method argument is automatically enforced (if you do not use varargs) and you will immediately notice something is missing. In a way it is more obvious. And then there are still the other advantages - thread safety - no permanent side effects - no need to invoke additional methods before this method to set instance state properly etc. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/