On 09/28/2010 03:49 AM, Trevor Hinesley wrote:
> Hey guys,
>
> I'm slowly getting the hang of Ruby, I'm a Java guy by trade. I really
> like Ruby and am picking up on it pretty quickly, but for some reason my
> overload of the "+" operator is not working. Here is the code:
>
> class Overloading
> def -(a)
>    return -a
> end
> b = 2-4
> puts "#{b}"
> end
>
> Basically, I'm trying to turn the minus operator into a plus operator
> for a project to show how operator overloading in Ruby works, but this
> isn't working from some reason, and I'm not sure why.
>
> Help?

This might be interesting for you:

http://blog.rubybestpractices.com/posts/rklemme/019-Complete_Numeric_Class.html

Kind regards

	robert