From 510d0bf470681de77e46bbfb48c8b12814a7c4c8 Mon Sep 17 00:00:00 2001 From: Noskov Artem Date: Wed, 12 Feb 2020 10:20:30 +0500 Subject: [PATCH] Fixed Go questions Added answers for go questions --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index fe64fde..a68bc8b 100644 --- a/README.md +++ b/README.md @@ -4765,6 +4765,11 @@ func main() { } ```
+ +Constants in Go can only be declared using constant expressions. +But `x`, `y` and their sum is variable. +
+const initializer x + y is not a constant
@@ -4788,10 +4793,21 @@ func main() { } ```
+ +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. +
+`x` and `y` in the first iota group, `z` in the second. +
+[Iota page in Go Wiki](https://github.com/golang/go/wiki/Iota)
What _ is used for in Go?
+ +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). +
+[answer in SO](https://stackoverflow.com/questions/27764421/what-is-underscore-comma-in-a-go-declaration#answer-27764432)
@@ -4812,6 +4828,8 @@ func main() { } ```
+ +Since the first iota is declared with the value `3` (` + 3`), the next one has the value `4`
## Mongo