diff options
Diffstat (limited to 'doc/docs')
| -rwxr-xr-x | doc/docs/doc/README.md | 14 | ||||
| -rwxr-xr-x | doc/docs/zh/doc/README.md | 15 |
2 files changed, 27 insertions, 2 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 7e9b454..a970baa 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
| @@ -3538,7 +3538,7 @@ with str := "Hello" | |||
| 3538 | </pre> | 3538 | </pre> |
| 3539 | </YueDisplay> | 3539 | </YueDisplay> |
| 3540 | 3540 | ||
| 3541 | Accessing special keys with `[]` in a `with` statement. | 3541 | You can access special keys with `[]` in a `with` statement. |
| 3542 | 3542 | ||
| 3543 | ```moonscript | 3543 | ```moonscript |
| 3544 | with tb | 3544 | with tb |
| @@ -3561,6 +3561,18 @@ with tb | |||
| 3561 | </pre> | 3561 | </pre> |
| 3562 | </YueDisplay> | 3562 | </YueDisplay> |
| 3563 | 3563 | ||
| 3564 | `with?` is an enhanced version of `with` syntax, which introduces an existential check to safely access objects that may be nil without explicit null checks. | ||
| 3565 | |||
| 3566 | ```moonscript | ||
| 3567 | with? obj | ||
| 3568 | print obj.name | ||
| 3569 | ``` | ||
| 3570 | <YueDisplay> | ||
| 3571 | <pre> | ||
| 3572 | with? obj | ||
| 3573 | print obj.name | ||
| 3574 | </pre> | ||
| 3575 | </YueDisplay> | ||
| 3564 | 3576 | ||
| 3565 | ## Do | 3577 | ## Do |
| 3566 | 3578 | ||
diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md index da90fa6..2d4af18 100755 --- a/doc/docs/zh/doc/README.md +++ b/doc/docs/zh/doc/README.md | |||
| @@ -3494,7 +3494,7 @@ with str := "你好" | |||
| 3494 | </pre> | 3494 | </pre> |
| 3495 | </YueDisplay> | 3495 | </YueDisplay> |
| 3496 | 3496 | ||
| 3497 | 在with语句中可用`[]`访问特殊键。 | 3497 | 你以 `with` 语句中使用 `[]` 访问特殊键。 |
| 3498 | 3498 | ||
| 3499 | ```moonscript | 3499 | ```moonscript |
| 3500 | with tb | 3500 | with tb |
| @@ -3517,6 +3517,19 @@ with tb | |||
| 3517 | </pre> | 3517 | </pre> |
| 3518 | </YueDisplay> | 3518 | </YueDisplay> |
| 3519 | 3519 | ||
| 3520 | `with?` 是 `with` 语法的一个增强版本,引入了存在性检查,用于在不显式判空的情况下安全访问可能为 nil 的对象。 | ||
| 3521 | |||
| 3522 | ```moonscript | ||
| 3523 | with? obj | ||
| 3524 | print obj.name | ||
| 3525 | ``` | ||
| 3526 | <YueDisplay> | ||
| 3527 | <pre> | ||
| 3528 | with? obj | ||
| 3529 | print obj.name | ||
| 3530 | </pre> | ||
| 3531 | </YueDisplay> | ||
| 3532 | |||
| 3520 | ## do 语句 | 3533 | ## do 语句 |
| 3521 | 3534 | ||
| 3522 | 当用作语句时,do语句的作用就像在Lua中差不多。 | 3535 | 当用作语句时,do语句的作用就像在Lua中差不多。 |
