From 29db60797bd74656b57a0f20778c76adc78095ac Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sat, 28 Feb 2026 18:03:14 +0800 Subject: Fixed destructuring with empty and comment lines in table issue. Updated docs. --- .../zh/doc/objects/object-oriented-programming.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'doc/docs/zh') 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   此外,“@” 前缀在变量名上起到了简化作用,代表 “self”。例如,`@items` 就等同于 `self.items`。 +  类定义块中也支持通过尖括号写元方法字段,例如 ``。 + +```yuescript +class User + new: (@name) => + : => "User(#{@name})" + +print tostring User "Yue" +``` + + + +```yue +class User + new: (@name) => + : => "User(#{@name})" + +print tostring User "Yue" +``` + + +   为了创建类的一个新实例,可以将类名当作一个函数来调用,这样就可以生成并返回一个新的实例。 ```yuescript -- cgit v1.2.3-55-g6feb