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

Class Magic Functions - Invert

This allows a class to override the ~~ operator for example:

// define a class
class test
{
    my $x;
    my $y;
    Function __Construct($a, $b)
    {
        $x = ~~$a;
        $y = ~~$b;
    }
    Function __Invert()
    {
        $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 invert operator on the class
~~$a;

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

// PRINTS
// First Values = X:720575940379279360 Y:1441151880758558720
// Second Values = X:10 Y:20

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


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