1. 程式人生 > >Go/函式/回撥函式

Go/函式/回撥函式

## 回撥函式

package main

import "fmt"

type FuncType func (int,int) int

//函式型別作為引數
func callBack(a,b int, f FuncType) (c int){
	c = f(a,b)
	return
}

func test(a,b int) int{
	return a*b
}

func main(){
	c := callBack(1,2,test)
	fmt.Println(c)
}