Merge pull request #76 from noartem/master

Fixed Go questions
This commit is contained in:
Arie Bregman 2020-02-12 11:29:55 +02:00 committed by GitHub
commit 8ff61d7912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4765,6 +4765,11 @@ func main() {
} }
``` ```
</summary><br><b> </summary><br><b>
Constants in Go can only be declared using constant expressions.
But `x`, `y` and their sum is variable.
<br>
<code>const initializer x + y is not a constant</code>
</b></details> </b></details>
<details> <details>
@ -4788,10 +4793,21 @@ func main() {
} }
``` ```
</summary><br><b> </summary><br><b>
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.
<br>
`x` and `y` in the first iota group, `z` in the second.
<br>
[Iota page in Go Wiki](https://github.com/golang/go/wiki/Iota)
</b></details> </b></details>
<details> <details>
<summary>What _ is used for in Go?</summary><br><b> <summary>What _ is used for in Go?</summary><br><b>
It avoids having to declare all the variables for the returns values.
It is called the [blank identifier](https://golang.org/doc/effective_go.html#blank).
<br>
[answer in SO](https://stackoverflow.com/questions/27764421/what-is-underscore-comma-in-a-go-declaration#answer-27764432)
</b></details> </b></details>
<details> <details>
@ -4812,6 +4828,8 @@ func main() {
} }
``` ```
</summary><br><b> </summary><br><b>
Since the first iota is declared with the value `3` (` + 3`), the next one has the value `4`
</b></details> </b></details>
## Mongo ## Mongo