aboutsummaryrefslogtreecommitdiff
path: root/examples/18-struct-positional-fields
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-02-02 20:13:05 +0000
committerMichael Williamson <mike@zwobble.org>2025-02-02 20:13:20 +0000
commit89394d0fab076765b637b0fe643d8f8950639817 (patch)
tree6852b4f81fd7f7812bb208df52b4e0cc8b1bcbdf /examples/18-struct-positional-fields
parent67f010c93b11744b1f2f1c9403fd1e8d2b888acb (diff)
Add int arithmetic example
Diffstat (limited to 'examples/18-struct-positional-fields')
-rw-r--r--examples/18-struct-positional-fields/shed-examples.json59
-rw-r--r--examples/18-struct-positional-fields/shed.json58
-rw-r--r--examples/18-struct-positional-fields/src/HelloWorld.shed17
3 files changed, 34 insertions, 0 deletions
diff --git a/examples/18-struct-positional-fields/shed-examples.json5 b/examples/18-struct-positional-fields/shed-examples.json5
new file mode 100644
index 00000000..531c665f
--- /dev/null
+++ b/examples/18-struct-positional-fields/shed-examples.json5
@@ -0,0 +1,9 @@
+{
+ examples: [
+ {
+ project: ".",
+ bin: "hello-world",
+ expectedOutput: "hello, world",
+ },
+ ],
+}
diff --git a/examples/18-struct-positional-fields/shed.json5 b/examples/18-struct-positional-fields/shed.json5
new file mode 100644
index 00000000..a6c8e563
--- /dev/null
+++ b/examples/18-struct-positional-fields/shed.json5
@@ -0,0 +1,8 @@
+{
+ bins: [
+ {
+ name: "hello-world",
+ mainNamespace: "HelloWorld",
+ },
+ ],
+}
diff --git a/examples/18-struct-positional-fields/src/HelloWorld.shed b/examples/18-struct-positional-fields/src/HelloWorld.shed
new file mode 100644
index 00000000..8880c7e2
--- /dev/null
+++ b/examples/18-struct-positional-fields/src/HelloWorld.shed
@@ -0,0 +1,17 @@
+pub fun main() ! Io -> Unit {
+ val messageParts = getMessageParts();
+ print!(messageParts.part1);
+ print!(messageParts.part2);
+}
+
+// We put part2 before part1 so that the order of args differs from the lexical
+// field order.
+struct MessageParts(
+ part2: String,
+ part1: String,
+) {
+}
+
+fun getMessageParts() -> MessageParts {
+ MessageParts("world\n", "hello, ")
+}