Skip to content

Commit 00d0d24

Browse files
authored
Merge pull request #1993 from xushiwei/q
mini spec: zero value
2 parents 215ee54 + d5f5620 commit 00d0d24

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/spec-mini.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,3 +1773,22 @@ Here is a complete Go+ package that implements XXX.
17731773
```go
17741774
TODO
17751775
```
1776+
1777+
## Program initialization and execution
1778+
1779+
### The zero value
1780+
1781+
When storage is allocated for a [variable](#variables), either through a declaration or a call of `new`, or when a new value is created, either through a composite literal or a call of `make`, and no explicit initialization is provided, the variable or value is given a default value. Each element of such a variable or value is set to the _zero_ value for its type: `false` for booleans, `0` for numeric types, `""` for strings, and `nil` for pointers, functions, interfaces, slices, and maps. This initialization is done recursively, so for instance each element of an array of structs will have its fields zeroed if no value is specified.
1782+
1783+
These two simple declarations are equivalent:
1784+
1785+
```go
1786+
var i int
1787+
var i int = 0
1788+
```
1789+
1790+
TODO
1791+
1792+
### Package initialization
1793+
1794+
TODO

0 commit comments

Comments
 (0)