知识卡片
声明与零值形成默认状态
var可显式写类型或由初始化表达式推断,未显式初始化时获得该类型零值;函数内短声明:=须引入至少一个新的非空白变量,并注意作用域。const须在声明时给出常量表达式,不能以后修改。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Go Language Foundations · 查看原书依据
When a variable is declared without an explicit value, it’s assigned to the zero value for its type: Integers: 0 Floats: 0.0 Booleans: false Strings: "" (the empty string) Constants Constants are very similar to variables, using the const keyword to associate an identifier with some typed value. However, constants differ from variables in some
参考来源
- 位置:《Cloud Native Go》第03章《Go Language Foundations》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch03.xhtml)
- 结论依据:var可显式写类型或由初始化表达式推断,未显式初始化时获得该类型零值;函数内短声明:=须引入至少一个新的非空白变量,并注意作用域。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:When a variable is declared without an explicit value, it’s assigned to the zero value for its type: Integers: 0 Floats: 0.0 Booleans: false Strings: "" (the empty string) Constants Constants are very similar to variables, using the const keyword to associate an identifier with some typed value. However, constants differ from variables in some