We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1c36823 commit 69d6f9eCopy full SHA for 69d6f9e
src/essential/impl/err/3.nil.md
@@ -8,7 +8,7 @@
8
type A struct {
9
b B
10
c C
11
- d D
+ d D
12
}
13
14
func (a A) Close() error {
@@ -197,14 +197,18 @@ func main() {
197
198
```
199
200
-当 map 为`nil`的时候,还可以对其进行访问
+当 map 为`nil`的时候,还可以对其进行访问,但`nil`的 map 是只读的,一旦尝试写入就会引发panic
201
202
```go
203
func main() {
204
var s map[string]int
205
i, ok := s[""]
206
fmt.Println(i, ok)
207
fmt.Println(len(s))
208
+
209
+ // 尝试写入时,会引发panic
210
+ s["a"] = 1 // panic: assignment to entry in nil map
211
212
213
214
0 commit comments