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)
}

猜你喜欢

转载自blog.csdn.net/qq_24243483/article/details/84037793