package main

import "fmt"

// section: type
type Temperature float64

// section: type

// section: methods
// Methods CAN be defined on custom types
func (t Temperature) Celsius() float64 {
	return float64(t)
}

func (t Temperature) Fahrenheit() float64 {
	return float64(t)*9/5 + 32
}

// section: methods

func main() {
	// section: main
	var temp Temperature = 100.0
	fmt.Printf("%.1f°C = %.1f°F\n", temp.Celsius(), temp.Fahrenheit())

	// But the underlying type (float64) does NOT get those methods
	var f float64 = 100.0
	_ = f
	// f.Celsius() // ERROR: float64 has no method Celsius
	// section: main
}

/*
// section: output
$ go run main.go
100.0°C = 212.0°F
// section: output
*/
