On Thu, May 10, 2012 at 8:18 AM, sam jam <lists / ruby-forum.com> wrote:
> So pretty much instance variables to pass between methods in a class,
> and () to pass between classes?

I definitively disagree.  The purpose of instance variables is to
carry the state of an instance.  In your example you are using state
only for the purpose of the method invocation.  Using instance
variables has side effects: the instance is changed after the method
returns and they are not thread safe without additional measures.  So
in your case you are introducing unnecessary disadvantages.  So it's
definitively

def first
  last("sam")
end

def last(first)
  first + " " + "jam"
end

Note the subtle changes I did: you set name in last but you do not do
anything with the value, so I left it out and simply returned the
result.  Also, I left variable "name" out of method #first because the
value is used in one place only anyway.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/