From: Christopher Carver Date: 2009-06-16T01:43:31+09:00 Subject: Re: confusion about object method scoping I just realized I made a couple of typos. I forgot to pass an argument to Calculator.factorial and in factorial I used the = operator instead of +=. But I think you see what I am trying to do. How can I make a class method callable by another method in that class? On Mon, Jun 15, 2009 at 12:31 PM, Christopher Carver wrote: > Hello, > > I am defining a class.  That class has several methods.  In one of the > class methods I'm trying to use a previously defined method.  It's > throwing an exception.  Here's some code that demonstrates my problem. >  Am I really unable to have a class use some of it's own methods if > they've already been defined?  Thanks in advance! > > class Calculator > >  private >  def add(x,y) >   x+y >  end > >  public >  def Calculator.factorial(x) >   result = 0 > >   (1..x).each { |number| >     result = add(result,number) >   } > >   result >  end > > end > > puts Calculator.factorial() >