Skip to content

Commit 510d0bf

Browse files
authored
Fixed Go questions
Added answers for go questions
1 parent af08441 commit 510d0bf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,6 +4765,11 @@ func main() {
47654765
}
47664766
```
47674767
</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>
47684773
</b></details>
47694774

47704775
<details>
@@ -4788,10 +4793,21 @@ func main() {
47884793
}
47894794
```
47904795
</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)
47914802
</b></details>
47924803

47934804
<details>
47944805
<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)
47954811
</b></details>
47964812

47974813
<details>
@@ -4812,6 +4828,8 @@ func main() {
48124828
}
48134829
```
48144830
</summary><br><b>
4831+
4832+
Since the first iota is declared with the value `3` (` + 3`), the next one has the value `4`
48154833
</b></details>
48164834

48174835
## Mongo

0 commit comments

Comments
 (0)