diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
| commit | 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 (patch) | |
| tree | 34d44c9330dc3ec71fc850b95b3412a1ce292cb8 /docs | |
| parent | a571ccffd795a595e990a3405dcf977aafc33c6c (diff) | |
Switch to using optional return values for list indexing.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/lists.md | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/docs/lists.md b/docs/lists.md index dfb64aad..d12a0b5b 100644 --- a/docs/lists.md +++ b/docs/lists.md @@ -62,24 +62,23 @@ last item, `-2` is the second-to-last, and so on. ```tomo list := [10, 20, 30, 40] >> list[1] -= 10 += 10? >> list[2] -= 20 += 20? + +>> list[999] += none >> list[-1] -= 40 += 40? >> list[-2] -= 30 += 30? ``` If a list index of `0` or any value larger than the length of the list is -used, it will trigger a runtime error that will print what the invalid list -index was, the length of the list, and a stack trace. As a performance -operation, if list bounds checking proves to be a performance hot spot, you -can explicitly disable bounds checking by adding `list[i; unchecked]` to the -list access. +used, a `none` value will be returned. ## Iteration |
