diff --git a/moonbit-docs/docs/README.md b/moonbit-docs/docs/README.md index 81580713..58aeca2f 100644 --- a/moonbit-docs/docs/README.md +++ b/moonbit-docs/docs/README.md @@ -443,6 +443,7 @@ even: 6 ``` ### `for .. in` loop + MoonBit supports traversing elements of different data structures and sequences via the `for .. in` loop syntax: ```moonbit @@ -485,7 +486,6 @@ test "map test" { If a loop variable is unused, it can be ignored with `_`. - ### Functional loop Functional loop is a powerful feature in MoonBit that enables you to write loops in a functional style. @@ -1257,6 +1257,8 @@ Currently, the following operators can be overloaded: | `/` | `op_div` | | `%` | `op_mod` | | `=` | `op_equal` | +| `<<` | `op_shl` | +| `>>` | `op_shr` | | `-` (unary) | `op_neg` | | `_[_]` (get item) | `op_get` | | `_[_] = _` (set item) | `op_set` | @@ -1327,8 +1329,8 @@ MoonBit supports C-Style bitwise operators for both 32 bits and 64 bits `Int` an | `&` | `land` | | `\|` | `lor` | | `^` | `lxor` | -| `<<` | `lsl` | -| `>>` | `lsr` | +| `<<` | `shl` | +| `>>` | `shr` | ## Error Handling diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/README.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/README.md index 3a6cd17e..e04edbe3 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/README.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/README.md @@ -443,6 +443,7 @@ even: 6 ``` ### `for .. in` 循环 + MoonBit 使用 `for .. in` 循环语法来遍历各种数据结构和序列: ```moonbit @@ -463,6 +464,7 @@ for k, v in { "x": 1, "y": 2, "z": 3 } { ``` 下面是另一个有两个循环变量的 `for .. in` 的例子,在遍历一个数组的同时追踪这是数组中的第几个元素: + ```moonbit for index, elem in [ 4, 5, 6 ] { let i = index + 1 @@ -1220,6 +1222,8 @@ fn init { | `/` | `op_div` | | `%` | `op_mod` | | `=` | `op_equal` | +| `<<` | `op_shl` | +| `>>` | `op_shr` | | `-`(一元运算符) | `op_neg` | | `_[_]`(获取项) | `op_get` | | `_[_] = _`(设置项) | `op_set` | @@ -1290,8 +1294,8 @@ MoonBit 支持 C 风格的位运算符,可用于 32 位和 64 位的 `Int` 和 | `&` | `land` | | `\|` | `lor` | | `^` | `lxor` | -| `<<` | `lsl` | -| `>>` | `lsr` | +| `<<` | `shl` | +| `>>` | `shr` | ## 错误处理