you're my type - Defined Types - Defined types and operators
Head First Go、 Jay McGavren(著)、O’Reilly Media)の Chapter 9(you’re my type - Defined Types)、p.270(Pool Puzzle)の解答を求めてみる。
コード
main.go
package main
import "fmt"
type Population int
func main() {
var population Population
population = Population(572)
fmt.Println("Sleepy Creek County population:", population)
fmt.Println("Congratulations, Kevin and Anna! It's a girl!")
population += 1
fmt.Println("Sleepy Creek County population:", population)
}
入出力結果(Terminal, Zsh)
% go run ./main.go
Sleepy Creek County population: 572
Congratulations, Kevin and Anna! It's a girl!
Sleepy Creek County population: 573
%