From 89394d0fab076765b637b0fe643d8f8950639817 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 2 Feb 2025 20:13:05 +0000 Subject: Add int arithmetic example --- .../18-struct-positional-fields/shed-examples.json5 | 9 +++++++++ examples/18-struct-positional-fields/shed.json5 | 8 ++++++++ .../18-struct-positional-fields/src/HelloWorld.shed | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 examples/18-struct-positional-fields/shed-examples.json5 create mode 100644 examples/18-struct-positional-fields/shed.json5 create mode 100644 examples/18-struct-positional-fields/src/HelloWorld.shed (limited to 'examples/18-struct-positional-fields') 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, ") +} -- cgit v1.2.3