From 4acaa7458fe4c185d885de437d269882d6ca9e79 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 17 Apr 2022 14:21:58 +0200 Subject: [PATCH] Fix `late` doc --- docs/Overview/declaration.mdr | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 -- 2.43.0