mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-10-25 15:51:37 +00:00
make loop
This commit is contained in:
@@ -10,7 +10,7 @@ fmt.Println(len(s)) // "12"
|
||||
fmt.Println(s[0], s[7]) // "104 119" ('h' and 'w')
|
||||
```
|
||||
|
||||
如果視圖訪問超齣字符串范圍的字節將會導致panic異常:
|
||||
如果視圖訪問超出字符串范圍的字節將會導致panic異常:
|
||||
|
||||
```Go
|
||||
c := s[len(s)] // panic: index out of range
|
||||
@@ -24,7 +24,7 @@ c := s[len(s)] // panic: index out of range
|
||||
fmt.Println(s[0:5]) // "hello"
|
||||
```
|
||||
|
||||
同樣, 如果索引超齣字符串范圍或者j小於i的話將導致panic異常.
|
||||
同樣, 如果索引超出字符串范圍或者j小於i的話將導致panic異常.
|
||||
|
||||
不管i還是j都可能被忽略, 當它們被忽略時將采用0作爲開始位置, 采用 len(s) 作爲接受的位置.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user