diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-10-29 21:53:47 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-10-29 21:54:16 +0000 |
| commit | 59ec0a666ee265e7726cd76f8362d47cdbe28c1d (patch) | |
| tree | 1571d15c7cacdfb05285cdbfae517af988d77f91 | |
| parent | 323c351da52c1c74b388dbd8f6c0e29bbccb792b (diff) | |
Add example of inferring param type
| -rw-r--r-- | examples/20-function-expression-infer-param-type/shed.toml | 7 | ||||
| -rw-r--r-- | examples/20-function-expression-infer-param-type/src/HelloWorld.shed | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/20-function-expression-infer-param-type/shed.toml b/examples/20-function-expression-infer-param-type/shed.toml new file mode 100644 index 00000000..1503d826 --- /dev/null +++ b/examples/20-function-expression-infer-param-type/shed.toml @@ -0,0 +1,7 @@ +[[shed.bins]] +name = "hello-world" +main-namespace = "HelloWorld" + +[[shed.examples]] +bin = "hello-world" +expected-output = "hello, world\nworld, hello" diff --git a/examples/20-function-expression-infer-param-type/src/HelloWorld.shed b/examples/20-function-expression-infer-param-type/src/HelloWorld.shed new file mode 100644 index 00000000..e91bc5e0 --- /dev/null +++ b/examples/20-function-expression-infer-param-type/src/HelloWorld.shed @@ -0,0 +1,8 @@ +pub fun main() ! Io -> Unit { + printHelloWorld!(fn (left, right) { left + ", " + right + "\n" }); + printHelloWorld!(fn (left, right) { right + ", " + left + "\n" }) +} + +fun printHelloWorld(combine: fn (String, String) -> String) !Io -> Unit { + print!(combine("hello", "world")); +} |
