diff options
Diffstat (limited to 'doc/yue-en.md')
| -rw-r--r-- | doc/yue-en.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/yue-en.md b/doc/yue-en.md index 6680281..8f8370d 100644 --- a/doc/yue-en.md +++ b/doc/yue-en.md | |||
| @@ -508,6 +508,16 @@ Notice how all the methods in the class use the fat arrow function syntax. When | |||
| 508 | 508 | ||
| 509 | The @ prefix on a variable name is shorthand for self.. @items becomes self.items. | 509 | The @ prefix on a variable name is shorthand for self.. @items becomes self.items. |
| 510 | 510 | ||
| 511 | The class block also supports metatable fields by writing metamethod keys in angle brackets, such as `<tostring>`. | ||
| 512 | |||
| 513 | ```yuescript | ||
| 514 | class User | ||
| 515 | new: (@name) => | ||
| 516 | <tostring>: => "User(#{@name})" | ||
| 517 | |||
| 518 | print tostring User "Yue" | ||
| 519 | ``` | ||
| 520 | |||
| 511 | Creating an instance of the class is done by calling the name of the class as a function. | 521 | Creating an instance of the class is done by calling the name of the class as a function. |
| 512 | 522 | ||
| 513 | ```yuescript | 523 | ```yuescript |
