From 394ee0f64a0dc022f1dab86213d4771982ecf987 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sat, 28 Feb 2026 16:52:40 +0800 Subject: Updated docs. --- doc/docs/zh/doc/language-basics/operator.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'doc/docs/zh') diff --git a/doc/docs/zh/doc/language-basics/operator.md b/doc/docs/zh/doc/language-basics/operator.md index fc2a49d..6e3721f 100644 --- a/doc/docs/zh/doc/language-basics/operator.md +++ b/doc/docs/zh/doc/language-basics/operator.md @@ -138,6 +138,8 @@ tbA[] = ...tbB   你可以使用前置 `...` 操作符在 Lua 表中插入数组表或哈希表。 +  使用花括号字面量做表扩展(例如 `{...other}`)时,会复制 Lua 表中的数组部分和哈希部分。 + ```yuescript parts = * "shoulders" @@ -176,6 +178,30 @@ merge = {...a, ...b} +### 列表表扩展 + +  使用中括号字面量做表扩展(例如 `[...other,]`)时,只会复制 Lua 表中的数组部分。 + +```yuescript +source = {1, 2, 3, name: "Yue"} +fullCopy = {...source} +listCopy = [...source,] +-- fullCopy => {1, 2, 3, name: "Yue"} +-- listCopy => [1, 2, 3] +``` + + + +```yue +source = {1, 2, 3, name: "Yue"} +fullCopy = {...source} +listCopy = [...source,] +-- fullCopy => {1, 2, 3, name: "Yue"} +-- listCopy => [1, 2, 3] +``` + + + ## 表反向索引   你可以使用 **#** 操作符来反向索引表中的元素。 -- cgit v1.2.3-55-g6feb