From: Robert Klemme Date: 2011-10-04T15:06:19+09:00 Subject: Re: Operator Overloading On Tue, Oct 4, 2011 at 7:11 AM, Thescholar Thescholar wrote: > Let's suppose I have a class like this one and then I create two > objects: > > =-=-=-=-=-=-=-=-=-=-=-= > class Point > >  def initialize >    x = 5 >    y = 10 >    z = 25 >  end > > end > > a = Point.new > b = Point.new > =-=-=-=-=-=-=-=-=-=-=-= > > How do I do if I want to add a and b together to a new point called c? > Example: > > c = a + b > > How exactly should I implement the operator overloading feature? So that > x = 10, y = 20, z = 50. There are hardly any tutorial for this... > > Thank you! For a full blown example you can look here: http://blog.rubybestpractices.com/posts/rklemme/019-Complete_Numeric_Class.html Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/