From: Jérémie Astor Date: Sun, 17 Apr 2022 12:21:58 +0000 (+0200) Subject: Fix `late` doc X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=4acaa7458fe4c185d885de437d269882d6ca9e79;p=gwion.git Fix `late` doc --- diff --git a/docs/Overview/declaration.mdr b/docs/Overview/declaration.mdr index 5bba1a98..ca872316 100644 --- a/docs/Overview/declaration.mdr +++ b/docs/Overview/declaration.mdr @@ -11,11 +11,21 @@ var Object o; ## Declaring a reference +sometimes you just want an object to be instantiated later. +This is done using the `late` keyword ```gwion,editable late Object object_ref; -<<< "Reference points to no object yet: ", object_ref >>>; -new Object => object_ref; -<<< "But now it does: ", 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` +```gwion,editable +late Object object_ref; +<<< object_ref >>>; ``` ## Arrays