Declarations

Basics

Declaring a primitive or an object is quite straight forward:

var int i;
var Object o;
<<< i, " ", o >>>;

Declaring a reference

sometimes you just want an object to be instantiated later. This is done using the late keyword

late Object object_ref;

if(object_ref)
  <<< "We have an object: ", object_ref >>>;
else
  <<< "We have no object" >>>;

trying to access, print or pass an non instantiated object will perform NullPtrException

late Object object_ref;
<<< object_ref >>>;

Arrays

array as refs

var int array_ref[];
new int[2] :=> array_ref;
<<< array_ref >>>;
built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground