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. --- .../doc/objects/object-oriented-programming.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'doc/docs/id-id') diff --git a/doc/docs/id-id/doc/objects/object-oriented-programming.md b/doc/docs/id-id/doc/objects/object-oriented-programming.md index 7d5d420..cc74690 100644 --- a/doc/docs/id-id/doc/objects/object-oriented-programming.md +++ b/doc/docs/id-id/doc/objects/object-oriented-programming.md @@ -40,6 +40,28 @@ Perhatikan bahwa semua method di kelas menggunakan sintaks fungsi panah tebal. S Prefiks `@` pada nama variabel adalah singkatan untuk `self.`. `@items` menjadi `self.items`. +Blok kelas juga mendukung field metatable dengan menulis key metamethod dalam tanda kurung sudut, misalnya ``. + +```yuescript +class User + new: (@name) => + : => "User(#{@name})" + +print tostring User "Yue" +``` + + + +```yue +class User + new: (@name) => + : => "User(#{@name})" + +print tostring User "Yue" +``` + + + Membuat instance kelas dilakukan dengan memanggil nama kelas sebagai fungsi. ```yuescript -- cgit v1.2.3-55-g6feb