aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-16 16:46:38 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-16 16:46:38 -0800
commit517d661368611fe753e9fd97a7adb2e45fca745e (patch)
tree7949d825625feddfc6b3e40c3ea9d26da199529f /examples
parent75bb8979aee185e82de0e3a5b82d88774997a634 (diff)
Updating documentation
Diffstat (limited to 'examples')
-rw-r--r--examples/how_do_i.nom11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index 6e5d4d1..d4422f1 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -252,6 +252,17 @@ say both "Very very very very long first argument that needs its own line"
# This can be nested:
say both (my favorite number) and also "foo"
+# Object-oriented programming:
+# How do I define a class?
+a (Vec) is a thing:
+ ($its, + $other) means (Vec {.x = ($its.x + $other.x), .y = ($its.y + $other.y)})
+ ($its, length) means
+ sqrt ($its.x * $its.x + $its.y * $its.y)
+
+$v1 = (Vec {.x = 1, .y = 2})
+assume ($v1 + $v1) == (Vec {.x = 2, .y = 4})
+say $v1
+
# Macros:
# The "lua>" and "=lua" macros can be used to write raw lua code:
(say the time) means: