You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4765,6 +4765,11 @@ func main() {
4765
4765
}
4766
4766
```
4767
4767
</summary><br><b>
4768
+
4769
+
Constants in Go can only be declared using constant expressions.
4770
+
But `x`, `y` and their sum is variable.
4771
+
<br>
4772
+
<code>const initializer x + y is not a constant</code>
4768
4773
</b></details>
4769
4774
4770
4775
<details>
@@ -4788,10 +4793,21 @@ func main() {
4788
4793
}
4789
4794
```
4790
4795
</summary><br><b>
4796
+
4797
+
Go's iota identifier is used in const declarations to simplify definitions of incrementing numbers. Because it can be used in expressions, it provides a generality beyond that of simple enumerations.
4798
+
<br>
4799
+
`x` and `y` in the first iota group, `z` in the second.
4800
+
<br>
4801
+
[Iota page in Go Wiki](https://github.com/golang/go/wiki/Iota)
4791
4802
</b></details>
4792
4803
4793
4804
<details>
4794
4805
<summary>What _ is used for in Go?</summary><br><b>
4806
+
4807
+
It avoids having to declare all the variables for the returns values.
4808
+
It is called the [blank identifier](https://golang.org/doc/effective_go.html#blank).
4809
+
<br>
4810
+
[answer in SO](https://stackoverflow.com/questions/27764421/what-is-underscore-comma-in-a-go-declaration#answer-27764432)
4795
4811
</b></details>
4796
4812
4797
4813
<details>
@@ -4812,6 +4828,8 @@ func main() {
4812
4828
}
4813
4829
```
4814
4830
</summary><br><b>
4831
+
4832
+
Since the first iota is declared with the value `3` (` + 3`), the next one has the value `4`
0 commit comments