"Sputnik" help  
Sputnik Help
Language Reference - Classes - Class Magic Functions - Negate

Class Magic Functions - Negate

This allows a class to override the - operator (Negate mode only) for example:

// define a class
class test
{
    my $x;
    my $y;
    Function __Construct($a, $b)
    {
        $x = $a;
        $y = $b;
    }
    Function __BitwiseComplement()
    {
        $x = ~$x;
        $y = ~$y;
    }
}

// create new instance
my $a = new test(10, 20);

// find out the classes values
say "First Values = X:" . $a->$x . " Y:" . $a->$y;

// use the bitwise compliment operator on the class
~$a;

// find out the classes values
say "Second Values = X:" . $a->$x . " Y:" . $a->$y;

// PRINTS
// First Values = X:10 Y:20
// Second Values = X:-11 Y:-21

A full list of all possible magic functions can be found here.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org