diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-07-14 03:42:21 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-07-14 03:42:21 +0800 |
| commit | c6946ca162911036a19cc7c5deadb6d8c127755e (patch) | |
| tree | e728f31693d7fb1da3b5fca7f4ac5656392cf1f3 /doc/docs | |
| parent | 3159a45de9e691ad758dcbc933446f61b7ae1940 (diff) | |
| download | yuescript-c6946ca162911036a19cc7c5deadb6d8c127755e.tar.gz yuescript-c6946ca162911036a19cc7c5deadb6d8c127755e.tar.bz2 yuescript-c6946ca162911036a19cc7c5deadb6d8c127755e.zip | |
update doc and changelog.v0.13.4
Diffstat (limited to '')
| -rwxr-xr-x | doc/docs/doc/README.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index ef00c23..90cb309 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
| @@ -2343,19 +2343,23 @@ for item in *items | |||
| 2343 | You can use default values to optionally destructure the table for some fields. | 2343 | You can use default values to optionally destructure the table for some fields. |
| 2344 | 2344 | ||
| 2345 | ```moonscript | 2345 | ```moonscript |
| 2346 | item = x: 100 | 2346 | item = {} |
| 2347 | |||
| 2348 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | ||
| 2347 | 2349 | ||
| 2348 | switch item | 2350 | switch item |
| 2349 | when {:x, :y = 200} | 2351 | when {pos: {:x = 50, :y = 200}} |
| 2350 | print "Vec2 #{x}, #{y}" -- table matching will pass | 2352 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
| 2351 | ``` | 2353 | ``` |
| 2352 | <YueDisplay> | 2354 | <YueDisplay> |
| 2353 | <pre> | 2355 | <pre> |
| 2354 | item = x: 100 | 2356 | item = {} |
| 2357 | |||
| 2358 | {pos: {:x = 50, :y = 200}} = item -- get error: attempt to index a nil value (field 'pos') | ||
| 2355 | 2359 | ||
| 2356 | switch item | 2360 | switch item |
| 2357 | when {:x, :y = 200} | 2361 | when {pos: {:x = 50, :y = 200}} |
| 2358 | print "Vec2 #{x}, #{y}" -- table matching will pass | 2362 | print "Vec2 #{x}, #{y}" -- table destructuring will still pass |
| 2359 | </pre> | 2363 | </pre> |
| 2360 | </YueDisplay> | 2364 | </YueDisplay> |
| 2361 | 2365 | ||
