Skip to content

with

The with is a prepositional keyword used in conjunction with the new and construct keywords to pass constructor arguments.

Syntax

new T with {args};
new T[N] with {args};
construct T at addr with {args};

Example Code

class Point
{
    var int32 _x;
    var int32 _y;
};

int32 main()
{
    // heap allocation with initialization
    var Point* var p = new Point with { _x: 10, _y: 20 };

    // array allocation with initialization
    var Point* var arr = new Point[3] with { _x: 0, _y: 0 };

    delete arr;
    delete p;
    return 0;
}