basic/process_control/decision #104
Replies: 2 comments 1 reply
-
那个在if后面的| |闭包符号是干什么用的? |
Beta Was this translation helpful? Give feedback.
1 reply
-
好的😊
…---Original---
From: ***@***.***>
Date: Thu, Apr 25, 2024 21:40 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [zigcc/zig-course] basic/process_control/decision (Discussion#104)
可以看作类似 js 解构的操作,实际上是捕获内部的值,例如一个可选类型,if (a) |val|,如果 a 是可选类型?u8,那么当 a 不是 null,是会进入到内部并且val就是捕获的实际类型 u8
以此类推,它还可以捕获错误联合类型,并且如果是 |*val| 的形式,实际上 val 就是一个对应捕获类型的指针
这里的高级用法需要后面的可选类型和错误处理部分的知识,困惑是正常的。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
basic/process_control/decision
简单、快速地学习 Zig,ziglang中文教程,zig中文教程
https://course.ziglang.cc/basic/process_control/decision
Beta Was this translation helpful? Give feedback.
All reactions