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

Class Magic Functions - Construct

This function is immediately executed when an instance of a class is created.

// define a class
class test
{
    Function __Construct()
    {
        say "A test class is made";
    }
}

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

// PRINTS
// A test class is made

Of course you can pass variables into the constructor:

// define a class
class test
{
    Function __Construct($value)
    {
        say "A test class is made with value $value";
    }
}

// create new instance
my $a = new test("Hello");
my $b = new test("World");

// PRINTS
// A test class is made with value Hello
// A test class is made with value World

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


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