04-statements-expressions-comments/questions/01-statements/README.md
2: A statement can't produce a value. However, it can indirectly help to produce a value.
3: It surely can.
2: That's right. Go executes the code from top-to-bottom, one statement at a time.
1: It can't. Only a statement can do that.
3: It can't. Only a statement can do that.
1: It can't. Only a statement can do that.
2: It can't. Only a statement can do that.
package main
import "fmt"
func main() {
"Hello"
}
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println(runtime.NumCPU()); fmt.Println("cpus"); fmt.Println("the machine")
}
1: It works but that's not the reason. And, expressions can't be typed like that.
2: Are you sure?
3: That's right. Whether there's a semicolon or not; Go adds them automatically. Those statements are still assumed as they're on a different code line of their own.
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println(runtime.NumCPU() + 10)
}
1: That's right. + operator combines
runtime.NumCPU()and10expressions.2: No, they can't be. For example, you can't do this:
import "fmt" + 3. Some statement can allow expressions. However, this doesn't mean that they can be combined using expressions.3: That's right however it's irrelevant to why this code works.