summaryrefslogtreecommitdiff
path: root/examples/02-sum/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-05-02 09:33:20 +0100
committerMichael Williamson <mike@zwobble.org>2026-05-02 09:33:20 +0100
commit5d76fa1b86ff1bd15b9c6b546916bc03c9d9b9b4 (patch)
treec217496a632957cdeea37de3dd7106be2458c385 /examples/02-sum/src
parent3e1e789ab04226af17f58635be6367e69d9b655b (diff)
Add example for sum types
Diffstat (limited to 'examples/02-sum/src')
-rw-r--r--examples/02-sum/src/shapes.hob14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/02-sum/src/shapes.hob b/examples/02-sum/src/shapes.hob
new file mode 100644
index 0000000..08336c5
--- /dev/null
+++ b/examples/02-sum/src/shapes.hob
@@ -0,0 +1,14 @@
+sum Shape {
+ variant Rectangle;
+ variant Triangle;
+}
+
+struct Rectangle {
+ field width: Int32;
+ field height: Int32;
+}
+
+struct Triangle {
+ field width: Int32;
+ field height: Int32;
+}