Skip to content

Commit

Permalink
docs: correct shl shr
Browse files Browse the repository at this point in the history
  • Loading branch information
qazxcdswe123 committed Aug 16, 2024
1 parent 88b1a62 commit 3f536a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions moonbit-docs/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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` |
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ even: 6
```

### `for .. in` 循环

MoonBit 使用 `for .. in` 循环语法来遍历各种数据结构和序列:

```moonbit
Expand All @@ -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
Expand Down Expand Up @@ -1220,6 +1222,8 @@ fn init {
| `/` | `op_div` |
| `%` | `op_mod` |
| `=` | `op_equal` |
| `<<` | `op_shl` |
| `>>` | `op_shr` |
| `-`(一元运算符) | `op_neg` |
| `_[_]`(获取项) | `op_get` |
| `_[_] = _`(设置项) | `op_set` |
Expand Down Expand Up @@ -1290,8 +1294,8 @@ MoonBit 支持 C 风格的位运算符,可用于 32 位和 64 位的 `Int` 和
| `&` | `land` |
| `\|` | `lor` |
| `^` | `lxor` |
| `<<` | `lsl` |
| `>>` | `lsr` |
| `<<` | `shl` |
| `>>` | `shr` |

## 错误处理

Expand Down

0 comments on commit 3f536a6

Please sign in to comment.