Fixed Go questions
Added answers for go questions
This commit is contained in:
parent
af08441536
commit
510d0bf470
18
README.md
18
README.md
@ -4765,6 +4765,11 @@ func main() {
|
||||
}
|
||||
```
|
||||
</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>
|
||||
|
||||
<details>
|
||||
@ -4788,10 +4793,21 @@ func main() {
|
||||
}
|
||||
```
|
||||
</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>
|
||||
|
||||
<details>
|
||||
<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>
|
||||
|
||||
<details>
|
||||
@ -4812,6 +4828,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
</summary><br><b>
|
||||
|
||||
Since the first iota is declared with the value `3` (` + 3`), the next one has the value `4`
|
||||
</b></details>
|
||||
|
||||
## Mongo
|
||||
|
Loading…
Reference in New Issue
Block a user