From 525a4c6576c287cdaaeced4e4f1f53bb82515ad9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 11 Dec 2024 20:24:41 +0000 Subject: Rename 36-extensions example to 35-extend-struct-inline --- examples/35-extend-struct-inline/src/HelloWorld.shed | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/35-extend-struct-inline/src/HelloWorld.shed (limited to 'examples/35-extend-struct-inline/src/HelloWorld.shed') 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" + } + } +} -- cgit v1.2.3