Skip to content

Commit

Permalink
Update define-variable.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 authored and jinzhongjia committed Nov 1, 2024
1 parent 15be4c0 commit 0cbcc95
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions course/basic/define-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ PS:说实话,我认为这个设计并不太好。
::: details 小细节
为什么是作用域顶层呢?实际上,zig 将一个源码文件看作是一个容器。
:::

## 解构赋值(Destructuring Assignment)

解构赋值是 0.12 新引入的语法,允许对可索引的聚合结构(如元组、向量和数组)进行解构。

```zig
var z: u32 = undefined;
const x, var y, z = [3]u32{ 1, 2, 3 };
y += 10;
// x 是 1,y 是 12,z 是 3
```

0 comments on commit 0cbcc95

Please sign in to comment.