diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-28 18:03:14 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-28 18:03:14 +0800 |
| commit | 29db60797bd74656b57a0f20778c76adc78095ac (patch) | |
| tree | e7e54bb45011bb1dc5ba159c80dfffd396a61eed /doc/docs/zh | |
| parent | 394ee0f64a0dc022f1dab86213d4771982ecf987 (diff) | |
| download | yuescript-29db60797bd74656b57a0f20778c76adc78095ac.tar.gz yuescript-29db60797bd74656b57a0f20778c76adc78095ac.tar.bz2 yuescript-29db60797bd74656b57a0f20778c76adc78095ac.zip | |
Fixed destructuring with empty and comment lines in table issue. Updated docs.v0.33.7
Diffstat (limited to 'doc/docs/zh')
| -rw-r--r-- | doc/docs/zh/doc/objects/object-oriented-programming.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/docs/zh/doc/objects/object-oriented-programming.md b/doc/docs/zh/doc/objects/object-oriented-programming.md index 04f816a..270c2b3 100644 --- a/doc/docs/zh/doc/objects/object-oriented-programming.md +++ b/doc/docs/zh/doc/objects/object-oriented-programming.md | |||
| @@ -38,6 +38,28 @@ class Inventory | |||
| 38 | 38 | ||
| 39 |   此外,“@” 前缀在变量名上起到了简化作用,代表 “self”。例如,`@items` 就等同于 `self.items`。 | 39 |   此外,“@” 前缀在变量名上起到了简化作用,代表 “self”。例如,`@items` 就等同于 `self.items`。 |
| 40 | 40 | ||
| 41 |   类定义块中也支持通过尖括号写元方法字段,例如 `<tostring>`。 | ||
| 42 | |||
| 43 | ```yuescript | ||
| 44 | class User | ||
| 45 | new: (@name) => | ||
| 46 | <tostring>: => "User(#{@name})" | ||
| 47 | |||
| 48 | print tostring User "Yue" | ||
| 49 | ``` | ||
| 50 | |||
| 51 | <YueDisplay> | ||
| 52 | |||
| 53 | ```yue | ||
| 54 | class User | ||
| 55 | new: (@name) => | ||
| 56 | <tostring>: => "User(#{@name})" | ||
| 57 | |||
| 58 | print tostring User "Yue" | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 41 |   为了创建类的一个新实例,可以将类名当作一个函数来调用,这样就可以生成并返回一个新的实例。 | 63 |   为了创建类的一个新实例,可以将类名当作一个函数来调用,这样就可以生成并返回一个新的实例。 |
| 42 | 64 | ||
| 43 | ```yuescript | 65 | ```yuescript |
