diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-26 14:01:03 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-26 14:01:03 -0500 |
| commit | abe36dcee146fd1a13c338d8d65cd303dc223ed4 (patch) | |
| tree | eb94148dd12ec469439d78aab24a9d0010d22a51 /examples/learnxiny.tm | |
| parent | 4d11f83f706416c255374517efdcb82d37e42819 (diff) | |
Tweak docs
Diffstat (limited to 'examples/learnxiny.tm')
| -rw-r--r-- | examples/learnxiny.tm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm index 99649129..e31bab70 100644 --- a/examples/learnxiny.tm +++ b/examples/learnxiny.tm @@ -108,14 +108,19 @@ func main(): >> table:get("two") = 2 : Int? - # The value returned is optional (because the key might not be in the table). + # The value returned is optional because NONE will be returned if the key + # is not in the table: + >> table:get("xxx")! + = NONE : Int? + # Optional values can be converted to regular values using `!` (which will - # create a runtime error if the value is null) or the `or` operator: + # create a runtime error if the value is null): >> table:get("two")! = 2 : Int + # You can also use `or` to provide a fallback value to replace NONE: >> table:get("xxx") or 0 - = 0 + = 0 : Int # Empty tables require specifying the key and value types: empty_table := {:Text:Int} |
