Object oriented

newobj

Create a new object from a class, and run its constructor.

Syntax

define <Class> <name> is newobj <Class>(<args>);

How she behaves

  • The type is the class name.
  • Arguments are passed to define constructor.
  • This is not new. new leaves a variable empty. newobj builds someone.
  • You may type the variable as a parent (or abstract) class and build a child: define Shape shape is newobj Square(4.0);

Example

define Person jacob is newobj Person("Jacob", 21);

See also