1.函数也是有类型的
func (参数列表类型的数据类型)(返回值列表的数据类型)
/**
* @author ly (个人博客:https://www.cnblogs.com/qbbit)
* @date 2023/5/11 22:49
* @tags 喜欢就去努力的争取
*/
package main
import "fmt"
func main() {
a := 10
fmt.Printf("%T\n", a)
b := [4]int{1, 2, 3, 4}
fmt.Printf("%T\n", b)
c := []string{"Python", "Java", "GO"}
fmt.Printf("%T\n", c)
d := make(map[int]string)
d[1] = "zs"
fmt.Printf("%T\n", d)
// 函数的数据类型
fmt.Printf("%T\n", funType)
fmt.Printf("%T\n", funType2)
fmt.Printf("%T\n", funType3)
fmt.Printf("%T\n", funType4)
}
func funType() {
}
func funType2(num int) string {
return "ly"
}
func funType3(s string) string {
return "ly"
}
func funType4(a, b, c string, d map[int]string, e []int, f [2]string) (m1 map[string][]int, s1 string, arr [4]int) {
arr1 := [4]int{1, 2, 3, 4}
return nil, "", arr1
}