aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/typedmethods.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/typedmethods.zc
a
Diffstat (limited to 'tests/programs/typedmethods.zc')
-rw-r--r--tests/programs/typedmethods.zc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/programs/typedmethods.zc b/tests/programs/typedmethods.zc
new file mode 100644
index 0000000..facd9f1
--- /dev/null
+++ b/tests/programs/typedmethods.zc
@@ -0,0 +1,16 @@
+// struct methods declare a return type and typed parameters, like functions do
+struct Str {
+ int len;
+ static int size(int s) { return s * 2; }
+ int plus(int k) { return this.len + k; }
+ static fn none() { return 5; }
+}
+int main() {
+ Str a;
+ a.len = 9;
+ put_n(Str.size(7)); put_c(32);
+ put_n(Str.none()); put_c(32);
+ put_n(a.plus(4));
+ put_c(10);
+ return 0;
+}