Skip to content

Commit

Permalink
fix: 分割 PR 示例代码
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Nov 1, 2024
1 parent 225a8b7 commit b739ff3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
9 changes: 2 additions & 7 deletions course/basic/define-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ PS:说实话,我认为这个设计并不太好。

## 解构赋值(Destructuring Assignment)

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

```zig
var z: u32 = undefined;
const x, var y, z = [3]u32{ 1, 2, 3 };
y += 10;
// x 是 1,y 是 2,z 是 3
```
<<<@/code/release/define_variable.zig#deconstruct
13 changes: 13 additions & 0 deletions course/code/12/define_variable.zig
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ const Block = struct {
_ = x;
}
};

const Deconstruct = struct {
fn main() void {
// #region deconstruct
var z: u32 = undefined;
// var z: u32 = undefined;
const x, var y, z = [3]u32{ 1, 2, 3 };
y += 10;
// x 是 1,y 是 2,z 是 3
// #endregion deconstruct
_ = x;
}
};
13 changes: 13 additions & 0 deletions course/code/14/define_variable.zig
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ const Block = struct {
_ = x;
}
};

const Deconstruct = struct {
fn main() void {
// #region deconstruct
var z: u32 = undefined;
// var z: u32 = undefined;
const x, var y, z = [3]u32{ 1, 2, 3 };
y += 10;
// x 是 1,y 是 2,z 是 3
// #endregion deconstruct
_ = x;
}
};

0 comments on commit b739ff3

Please sign in to comment.