aboutsummaryrefslogtreecommitdiff
path: root/docs/enums.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-06 23:37:05 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-06 23:37:05 -0400
commit1a196aa8f724971e531487f9cdd541f7957cfd92 (patch)
tree52a36701065ab0e3f7012765c909c3b2a3fd2e49 /docs/enums.md
parent4a3db447ce820617a72bdd9fc6217c84c3799bea (diff)
Update syntax in docs
Diffstat (limited to 'docs/enums.md')
-rw-r--r--docs/enums.md18
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/enums.md b/docs/enums.md
index 45321d25..0a927831 100644
--- a/docs/enums.md
+++ b/docs/enums.md
@@ -15,14 +15,14 @@ c := VariousThings.Nothing
## Pattern Matching
-The values inside an enum can be accessed with pattern matching:
+The values inside an enum can be accessed with pattern matching
```tomo
-when x is AnInteger(i):
+when x is AnInteger(i)
say("It was $i")
-is TwoWords(x, y):
+is TwoWords(x, y)
say("It was $x and $y")
-is Nothing:
+is Nothing
say("It was nothing")
```
@@ -54,10 +54,10 @@ from a function with an explicit return type:
enum ArgumentType(AnInt(x:Int), SomeText(text:Text))
enum ReturnType(Nothing, AnInt(x:Int))
-func increment(arg:ArgumentType -> ReturnType):
- when arg is AnInt(x):
+func increment(arg:ArgumentType -> ReturnType)
+ when arg is AnInt(x)
return AnInt(x + 1)
- is SomeText:
+ is SomeText
return Nothing
...
@@ -78,9 +78,9 @@ known.
Enums can also define their own methods and variables inside their namespace:
```tomo
-enum VariousThings(AnInteger(i:Int), TwoWords(word1, word2:Text), Nothing):
+enum VariousThings(AnInteger(i:Int), TwoWords(word1, word2:Text), Nothing)
meaningful_thing := AnInteger(42)
- func doop(v:VariousThings):
+ func doop(v:VariousThings)
say("$v")
```