diff options
author | Li Jin <dragon-fly@qq.com> | 2023-08-09 10:17:57 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-08-09 10:17:57 +0800 |
commit | 949166b7db8ff195ce6f1d8d1fa34c242d267af1 (patch) | |
tree | 7300fe3cc676b02d7703513c6a97d8ac2121af31 /doc | |
parent | 33260af2175004347a3b9345b67727e596c6fffd (diff) | |
download | yuescript-949166b7db8ff195ce6f1d8d1fa34c242d267af1.tar.gz yuescript-949166b7db8ff195ce6f1d8d1fa34c242d267af1.tar.bz2 yuescript-949166b7db8ff195ce6f1d8d1fa34c242d267af1.zip |
update version and docs.v0.18.1
Diffstat (limited to 'doc')
-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 |