開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Go (プログラミング言語)
Head First Go (Jay McGavren(著)、O'Reilly Media)のChapter 2(which code runs next? - Conditionals and Loops)、Code Magnets(53)の解答を求めてみる。
コード
package main
import "fmt"
var a = "a"
func main() {
a = "a"
b := "b"
if true {
c := "c"
if true {
d := "d"
fmt.Println(a == "a")
fmt.Println(b == "b")
fmt.Println(c == "c")
fmt.Println(d == "d")
}
fmt.Println(a == "a")
fmt.Println(b == "b")
fmt.Println(c == "c")
// fmt.Println(d)
}
fmt.Println(a == "a")
fmt.Println(b == "b")
// fmt.Println(c)
// fmt.Println(d)
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ go run sample2.go true true true true true true true true true $
0 コメント:
コメントを投稿