Sign in
go
/
tour
/
c7374255f627de1d833c24ab73b75f6e7c25ef75
/
.
/
prog
/
methods-continued.go
blob: 397be474b98613201e889439a00b83646cd2b8c3 [
file
] [
log
] [
blame
]
package main
import (
"fmt"
"math"
)
type MyFloat float64
func (f MyFloat) Abs() float64 {
if f < 0 {
return float64(-f)
}
return float64(f)
}
func main() {
f := MyFloat(-math.Sqrt2)
fmt.Println(f.Abs())
}