Overloading prefix operators

Okay, so “operator overloading” is wonderfully trivial and natural in
Ruby but it just occured to me that I have no idea how to change the
behaviour of prefix operators like negate, “-x”, where x is an object…
How does one do this?
Thank you…

def -@
#do stuff here
end

On 11/28/06, Just Another Victim of the Ambient M. <

Just Another Victim of the Ambient M. wrote:

Okay, so “operator overloading” is wonderfully trivial and natural in
Ruby but it just occured to me that I have no idea how to change the
behaviour of prefix operators like negate, “-x”, where x is an object…

Look in the table here:
http://phrogz.net/ProgrammingRuby/language.html#operatorexpressions