From 4cce1013a2fbe4550228879d4d005ba7b04fb44f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 13 Sep 2024 20:25:09 -0400 Subject: [PATCH] Update pointer docs on optionals --- docs/pointers.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/pointers.md b/docs/pointers.md index ee7a5d8..b1d0fc1 100644 --- a/docs/pointers.md +++ b/docs/pointers.md @@ -101,12 +101,13 @@ optional := &foo? ``` The compiler will not allow you to dereference an optionally null pointer -without explicitly checking for null. To do so, use pattern matching like -this: +without explicitly checking for null. To do so, use a conditional check like +this, and everywhere inside the truthy block will allow you to use the pointer +as a non-null pointer: ``` -when optional is @ptr: - ok := ptr[] +if optional: + ok := optional[] else: say("Oh, it was null") ```