Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

method of int

package main

import (
	"fmt"
	"math"
)

type myint int

func (i myint) abs() float64 {
	return math.Abs(float64(i))
}

func main() {
	var n myint = -3
	fmt.Println(n.abs())
}
3