"Sputnik" help  
Sputnik Help
Language Reference - Classes - Class Cast Overrides - ToInt16

Class Cast Overrides - ToInt16

This allows a class to override the cast to a 16-Bit Unsigned Byte.

class Test
{
    my $i;
    my $j;
    Function __Construct($i, $j)
    {
        @this->$i = $i;
        @this->$j = $j;
    }
    Function __ToInt16()
    {
        say "__ToInt16 has been run";
        return $i + $j;
    }
}

my $a = new Test(64, 10);
say (int16)$a;

// PRINTS
// __ToInt16 has been run
// 74

A full list of all possible cast overrides can be found here.


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