diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-02 16:14:20 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-02 16:14:20 -0400 |
| commit | 6ec8f20fc506af4af5513803fb9a708e4f7b5040 (patch) | |
| tree | 8b952073f6eda5b85c375a65c73647a85fa16f27 /test/tables.tm | |
| parent | ecaf34247eb0728a913804033cf302dada417028 (diff) | |
Syntax change: table types are now: `{K=V; default=...}` and tables
use `{:K=V, ...; default=...}`
Diffstat (limited to 'test/tables.tm')
| -rw-r--r-- | test/tables.tm | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/tables.tm b/test/tables.tm index 9749835d..140fd1cf 100644 --- a/test/tables.tm +++ b/test/tables.tm @@ -22,7 +22,7 @@ func main(): >> t.length = 2 >> t.fallback - = none : {Text,Int} + = none : {Text=Int} >> t.keys = ["one", "two"] @@ -96,10 +96,25 @@ func main(): >> {1=1, 2=2} <> {2=2, 1=1} = Int32(0) - >> [{:Int,Int}, {0=0}, {99=99}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 2=-99, 3=3}, {1=1, 99=-99, 3=4}]:sorted() - = [{:Int,Int}, {0=0}, {1=1, 2=-99, 3=3}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 99=-99, 3=4}, {99=99}] + >> [{:Int=Int}, {0=0}, {99=99}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 2=-99, 3=3}, {1=1, 99=-99, 3=4}]:sorted() + = [{:Int=Int}, {0=0}, {1=1, 2=-99, 3=3}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 99=-99, 3=4}, {99=99}] >> [{:Int}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}]:sorted() = [{:Int}, {0, 3}, {1}, {1, 2}, {2}, {99}, {99}] + do: + # Default values: + counter := &{"x"=10; default=0} + >> counter["x"] + = 10 + >> counter["y"] + = 0 + >> counter:has("x") + = yes + >> counter:has("y") + = no + >> counter["y"] += 1 + >> counter + >> counter + = &{"x"=10, "y"=1; default=0} |
