From b37bd70b602b7ac6427dcf29f7cd9241b0a7ae09 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 10 Aug 2024 16:03:41 -0400 Subject: For tables, deprecate support for square bracket indexing and .default values, replacing them with a `:bump()` function for tables with numeric values. This means that counters can be implemented easily without the need to mask complexity. --- test/structs.tm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/structs.tm') diff --git a/test/structs.tm b/test/structs.tm index 4fdec6ae..c9022ede 100644 --- a/test/structs.tm +++ b/test/structs.tm @@ -29,11 +29,11 @@ func test_metamethods(): >> x < Pair(11, 20) = yes - >> t2 := {x:"found"; default="missing"} - >> t2[x] - = "found" - >> t2[y] - = "missing" + >> set := {x} + >> set:has(x) + = yes + >> set:has(y) + = no func test_mixed(): >> x := Mixed(10, "Hello") @@ -46,11 +46,11 @@ func test_mixed(): = no >> x < Mixed(11, "Hello") = yes - >> t := {x:"found"; default="missing"} - >> t[x] - = "found" - >> t[y] - = "missing" + >> set := {x} + >> set:has(x) + = yes + >> set:has(y) + = no func main(): test_literals() @@ -63,7 +63,7 @@ func main(): = Password(...) >> users_by_password := {my_pass:"User1", Password("xxx"):"User2"} = {Password(...):"User1", Password(...):"User2"} - >> users_by_password[my_pass] + >> users_by_password:get(my_pass) = "User1" >> CorecursiveA(@CorecursiveB()) -- cgit v1.2.3