aboutsummaryrefslogtreecommitdiff
path: root/examples/18-struct-positional-fields
diff options
context:
space:
mode:
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, ")
+}