blob: ffb457262b1ad2013435790b0ab5abfd6c0ed18d [file] [log] [blame]
Russ Coxe2195552021-11-18 12:03:46 -05001// +build ignore,OMIT
2
3package main
4
5import "fmt"
6
7type Celsius float32
8type Fahrenheit float32
9
10func (t Celsius) String() string { return fmt.Sprintf("%g°C", t) }
11func (t Fahrenheit) String() string { return fmt.Sprintf("%g°F", t) }
12func (t Celsius) ToFahrenheit() Fahrenheit { return Fahrenheit(t*9/5 + 32) }
13
14func main() {
15 var t Celsius = 21
16 fmt.Println(t.String())
17 fmt.Println(t)
18 fmt.Println(t.ToFahrenheit())
19}