From ccfe66f87663e10603e453f02894bb82dd23c93b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 19 Jan 2026 17:11:31 +0800 Subject: Made `;` work as statements separator. --- doc/docs/doc/README.md | 13 +++++++++++++ doc/docs/zh/doc/README.md | 13 +++++++++++++ 2 files changed, 26 insertions(+) (limited to 'doc/docs') diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index d862777..b5051d4 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -1588,6 +1588,19 @@ print ok, count, first YueScript is a whitespace significant language. You have to write some code block in the same indent with space **' '** or tab **'\t'** like function body, value list and some control blocks. And expressions containing different whitespaces might mean different things. Tab is treated like 4 space, but it's better not mix the use of spaces and tabs. +### Statement Separator + +A statement normally ends at a line break. You can also use a semicolon `;` to explicitly terminate a statement, which allows writing multiple statements on the same line: + +```moonscript +a = 1; b = 2; print a + b +``` + +
+a = 1; b = 2; print a + b
+
+
+ ### Multiline Chaining You can write multi-line chaining function calls with a same indent. diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md index 786892d..43713fe 100755 --- a/doc/docs/zh/doc/README.md +++ b/doc/docs/zh/doc/README.md @@ -1586,6 +1586,19 @@ print ok, count, first 月之脚本是一个对空白敏感的语言。你必须在相同的缩进中使用空格 **' '** 或制表符 **'\t'** 来编写一些代码块,如函数体、值列表和一些控制块。包含不同空白的表达式可能意味着不同的事情。制表符被视为4个空格,但最好不要混合使用空格和制表符。 +### 语句分隔符 + +一条语句通常以换行结束。你也可以使用分号 `;` 显式结束一条语句,从而在同一行中编写多条语句: + +```moonscript +a = 1; b = 2; print a + b +``` + +
+a = 1; b = 2; print a + b
+
+
+ ### 多行链式调用 你可以使用相同的缩进来编写多行链式函数调用。 -- cgit v1.2.3-55-g6feb