I don't understand why when I try to overload I get an error. Can I
overload somehow?

#!/usr/bin/env ruby

class Summer
  def sum(x)
    return x + 2
  end

  def sum(x,y)
    return x + y
  end

  def sum(x,y,z)
    return x + y + z
  end
end

s = Summer.new
puts s.sum(3)

ERROR:
ArgumentError: wrong number of arguments (1 for 3)

method sum  in summer.rb at line 18
at top level  in summer.rb at line 18


Ted

-- 
Posted via http://www.ruby-forum.com/.