重新回看了一遍 自己之前的笔记
看到switch 的功能
如下图
这样就判断出 x 是 一个参数为 i 返回值 为 float64 的函数
请问一下 那我如何 那着这个 x 去调用这个函数呢
func cheshi(i int) float64 {
fmt.Println("11111111111")
return float64(i)
}
func main() {
var x interface{}
x = cheshi
switch i := x.(type) {
case nil:
fmt.Printf(" x 的类型 :%T", i)
case int:
fmt.Printf("x 是 int 型")
case float64:
fmt.Printf("x 是 float64 型")
case func(int) float64:
fmt.Printf("x 是 func(int) 型")
case bool, string:
fmt.Printf("x 是 bool 或 string 型")
default:
fmt.Printf("未知型")
}
}