aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/doc/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/doc/README.md')
-rwxr-xr-xdoc/docs/doc/README.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md
index f0d67a5..309e124 100755
--- a/doc/docs/doc/README.md
+++ b/doc/docs/doc/README.md
@@ -2126,6 +2126,42 @@ if func 1, 2, 3,
2126</pre> 2126</pre>
2127</YueDisplay> 2127</YueDisplay>
2128 2128
2129### Parameter Destructuring
2130
2131YueScript now supports destructuring function parameters when the argument is an object. Two forms of destructuring table literals are available:
2132
2133* **Curly-brace wrapped literals/object parameters**, allowing optional default values when fields are missing (e.g., `{:a, :b}`, `{a: a1 = 123}`).
2134
2135* **Unwrapped simple table syntax**, starting with a sequence of key-value or shorthand bindings and continuing until another expression terminates it (e.g., `:a, b: b1, :c`). This form extracts multiple fields from the same object.
2136
2137```moonscript
2138f1 = (:a, :b, :c) ->
2139 print a, b, c
2140
2141f1 a: 1, b: "2", c: {}
2142
2143f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) ->
2144 print a, b, c
2145
2146arg1 = {a: 0}
2147f2 arg1, arg2
2148```
2149<YueDisplay>
2150<pre>
2151f1 = (:a, :b, :c) ->
2152 print a, b, c
2153
2154f1 a: 1, b: "2", c: {}
2155
2156f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) ->
2157print a, b, c
2158
2159arg1 = {a: 0}
2160f2 arg1, arg2
2161</pre>
2162</YueDisplay>
2163
2164
2129## Backcalls 2165## Backcalls
2130 2166
2131Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent. 2167Backcalls are used for unnesting callbacks. They are defined using arrows pointed to the left as the last parameter by default filling in a function call. All the syntax is mostly the same as regular arrow functions except that it is just pointing the other way and the function body does not require indent.