Merge pull request #63 from wenlei/master

增加了零值的例子,以及一些图例修改。
This commit is contained in:
astaxie
2012-10-12 09:38:31 -07:00
3 changed files with 18 additions and 2 deletions

20
2.2.md
View File

@@ -343,8 +343,8 @@ slice有一些简便的操作
- 长度,即`slice`的长度
- 最大长度,也就是`slice`开始位置到数组的最后位置的长度
array := [10]byte {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}
slice := A[4:8]
array := [10]byte {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j''k'}
slice := A[2:5]
上面代码的真正存储结构如下图所示
@@ -423,6 +423,22 @@ slice有一些简便的操作
![](images/2.2.makenew.png?raw=true)
关于“零值”,所指并非是空值,而是一种“变量未填充前”的默认值。通常为 0。
此处罗列 部分类型 的 “零值”
int 0
int8 0
int32 0
int64 0
uint 0x0
rune 0 //rune的实际类型是 int32
byte 0x0 // byte的实际类型是 uint8
float32 0 //长度为 4 byte
float64 0 //长度为 8 byte
bool false
string ""
## links