開発環境
- 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 3(call me - Functions)、Exercise(109)の解答を求めてみる。
コード
package main
import "fmt"
func negate(myBooleanPointer *bool) {
*myBooleanPointer = !*myBooleanPointer
}
func main() {
truth := true
negate(&truth)
fmt.Println(truth)
lies := false
negate(&lies)
fmt.Println(lies)
}
入出力結果(Bash、cmd(コマンドプロンプト)、Terminal)
$ go run sample3.go false true $
0 コメント:
コメントを投稿