modified: eBook/18.1.md

modified:   eBook/18.10.md
	modified:   eBook/18.2.md
	modified:   eBook/18.3.md
	modified:   eBook/18.6.md
	modified:   eBook/18.8.md
	modified:   eBook/18.9.md
This commit is contained in:
songleo
2016-01-03 14:43:12 +08:00
parent 0aefb4a032
commit b3550e98e3
7 changed files with 19 additions and 14 deletions

View File

@@ -1,15 +1,19 @@
# 18.2 数组和切片
创建: `arr1 := new([len]type)`
`slice1 := make([]type, len)`
初始化:`arr1 := [...]type{i1, i2, i3, i4, i5}`
`arrKeyValue := [len]type{i1: val1, i2: val2}`
`var slice1 []type = arr1[start:end]`
1如何截断数组或者切片的最后一个元素
`line = line[:len(line)-1]`
`line = line[:len(line)-1]`
2如何使用`for`或者`for-range`遍历一个数组(或者切片):