aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-13 20:25:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-13 20:25:09 -0400
commit4cce1013a2fbe4550228879d4d005ba7b04fb44f (patch)
treea8e9b33d86c9f4de0c87ed54b55357c8af1988f0
parentc455e7b67d2e55e6ed03e3449203d4e307f5a7dd (diff)
Update pointer docs on optionals
-rw-r--r--docs/pointers.md9
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/pointers.md b/docs/pointers.md
index ee7a5d8f..b1d0fc19 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")
```