開発環境
- 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 9(you're my type - Defined Types)、Pool Puzzle(270)の解答を求めてみる。
コード
package main
import "fmt"
type Population int
func main() {
var population Population
population = Population(572)
fmt.Println("Sleepy Creek Country population:", population)
fmt.Println("Congratulations, Kevin and Anna! It's a girl!")
population += 1
fmt.Println("Sleepy Creek Country population:", population)
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ go run sample1.go Sleepy Creek Country population: 572 Congratulations, Kevin and Anna! It's a girl! Sleepy Creek Country population: 573 $
0 コメント:
コメントを投稿