aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-04 01:57:34 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-04 01:57:34 -0400
commitc3f8b40c84e09543a5fbb2adf8b9563e42650696 (patch)
tree74e52ecc8f56b674db56276348a06c5c6c5c132c
parentdf844946f7d45fa39acf040eb8922ab658f9f5dd (diff)
Document empty tables/arrays
-rw-r--r--learnxiny.tm8
1 files changed, 8 insertions, 0 deletions
diff --git a/learnxiny.tm b/learnxiny.tm
index fcf25688..91590206 100644
--- a/learnxiny.tm
+++ b/learnxiny.tm
@@ -58,6 +58,11 @@ func main():
# Arrays:
my_numbers := [10, 20, 30]
+ # Empty arrays require specifying the type:
+ empty := [:Int]
+ >> empty.length
+ = 0
+
# Arrays are 1-indexed, so the first element is at index 1:
>> my_numbers[1]
= 10
@@ -110,6 +115,9 @@ func main():
# Otherwise, a runtime error will be raised:
# >> table:get("xxx")
+ # Empty tables require specifying the key and value types:
+ empty := {:Text:Int}
+
# Tables can be iterated over either by key or key,value:
for key in table:
pass