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

Class Magic Functions - IsZero

This allows a class to override all is zero tests within Sputnik when used on a class.for example:

// define a class
class test
{
    my $x;
    my $y;
    Function __Construct($a, $b)
    {
        $x = $a;
        $y = $b;
    }
    Function __IsZero()
    {
        return $x == 0 && $y == 0;
    }
}

// create new instance
my $a = new test(10, 20);
// show status
say "Status " . IsZero($a);
// set values to 0s
$a->$x = 0;
$a->$y = 0;
// show status
say "Status " . IsZero($a);

// PRINTS
// Status false
// Status true

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


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