diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-12-11 20:24:41 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-12-11 20:25:04 +0000 |
| commit | 525a4c6576c287cdaaeced4e4f1f53bb82515ad9 (patch) | |
| tree | 9aaeb245c17d824f636e00c8db0b892529f7970d /examples/35-extend-struct-inline | |
| parent | 1e2c50a6aa2a01bb93c5e13e23c9b33860407862 (diff) | |
Rename 36-extensions example to 35-extend-struct-inline
Diffstat (limited to 'examples/35-extend-struct-inline')
| -rw-r--r-- | examples/35-extend-struct-inline/shed.toml | 7 | ||||
| -rw-r--r-- | examples/35-extend-struct-inline/src/HelloWorld.shed | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/examples/35-extend-struct-inline/shed.toml b/examples/35-extend-struct-inline/shed.toml new file mode 100644 index 00000000..bf5c13c4 --- /dev/null +++ b/examples/35-extend-struct-inline/shed.toml @@ -0,0 +1,7 @@ +[[shed.bins]] +name = "hello-world" +main-namespace = "HelloWorld" + +[[shed.examples]] +bin = "hello-world" +expected-output = "hello, world" diff --git a/examples/35-extend-struct-inline/src/HelloWorld.shed b/examples/35-extend-struct-inline/src/HelloWorld.shed new file mode 100644 index 00000000..bcdcf023 --- /dev/null +++ b/examples/35-extend-struct-inline/src/HelloWorld.shed @@ -0,0 +1,20 @@ +pub fun main() ! Io -> Unit { + print!(Count(1).message()); + print!(Count(2).message()); + print!(Count(3).message()); +} + +struct Count(.value: Int) { +} + +extend Count { + fun message(this) -> String { + if (this.value == 1) { + "one\n" + } else if (this.value == 2) { + "two\n" + } else { + "many\n" + } + } +} |
