diff options
Diffstat (limited to '')
| -rwxr-xr-x | doc/docs/doc/README.md | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 4c8ac87..7e4aa22 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
| @@ -1181,6 +1181,28 @@ print "OK" | |||
| 1181 | </pre> | 1181 | </pre> |
| 1182 | </YueDisplay> | 1182 | </YueDisplay> |
| 1183 | 1183 | ||
| 1184 | ## Varargs Assignment | ||
| 1185 | |||
| 1186 | You can assign the results returned from a function to a varargs symbol `...`. And then access its content using the Lua way. | ||
| 1187 | ```moonscript | ||
| 1188 | list = {1, 2, 3, 4, 5} | ||
| 1189 | fn = (ok) -> ok, table.unpack list | ||
| 1190 | ok, ... = fn true | ||
| 1191 | count = select '#', ... | ||
| 1192 | first = select 1, ... | ||
| 1193 | print ok, count, first | ||
| 1194 | ``` | ||
| 1195 | <YueDisplay> | ||
| 1196 | <pre> | ||
| 1197 | list = {1, 2, 3, 4, 5} | ||
| 1198 | fn = (ok) -> ok, table.unpack list | ||
| 1199 | ok, ... = fn true | ||
| 1200 | count = select '#', ... | ||
| 1201 | first = select 1, ... | ||
| 1202 | print ok, count, first | ||
| 1203 | </pre> | ||
| 1204 | </YueDisplay> | ||
| 1205 | |||
| 1184 | ## Whitespace | 1206 | ## Whitespace |
| 1185 | 1207 | ||
| 1186 | Yuescript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. | 1208 | Yuescript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. |
| @@ -1299,7 +1321,7 @@ catch err | |||
| 1299 | 1321 | ||
| 1300 | ## Attributes | 1322 | ## Attributes |
| 1301 | 1323 | ||
| 1302 | Syntax support for Lua 5.4 attributes. But you can still use `const` declaration and get constant check working when targeting Lua versions below 5.4. | 1324 | Syntax support for Lua 5.4 attributes. And you can still use both the `const` and `close` declaration and get constant check and scoped callback working when targeting Lua versions below 5.4. |
| 1303 | 1325 | ||
| 1304 | ```moonscript | 1326 | ```moonscript |
| 1305 | const a = 123 | 1327 | const a = 123 |
