From 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 31 Aug 2025 23:33:22 -0400 Subject: Switch to using optional return values for list indexing. --- test/enums.tm | 4 ++-- test/iterators.tm | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/enums.tm b/test/enums.tm index 080e5d97..03eb6028 100644 --- a/test/enums.tm +++ b/test/enums.tm @@ -61,7 +61,7 @@ func main() i := 1 cases := [Foo.One(1), Foo.One(2), Foo.Zero] - while when cases[i] is One(x) + while when cases[i]! is One(x) >> x i += 1 @@ -77,7 +77,7 @@ func main() ] = ["Zero", "Small 1", "Small 2", "Other"] - >> expr := when cases[1] is One(y) + >> expr := when cases[1]! is One(y) y + 1 else -1 diff --git a/test/iterators.tm b/test/iterators.tm index 08382cff..c48e572b 100644 --- a/test/iterators.tm +++ b/test/iterators.tm @@ -4,9 +4,8 @@ struct Pair(x:Text, y:Text) func pairwise(strs:[Text] -> func(->Pair?)) i := 1 return func() - if i + 1 > strs.length return none i += 1 - return Pair(strs[i-1], strs[i])? + return Pair(strs[i-1] or return none, strs[i] or return none)? func range(first:Int, last:Int -> func(->Int?)) i := first -- cgit v1.2.3