package main
import "fmt"
func main() {
/* ret:= sum(3, 4)*/
r1, r2, r3, r4 := Cale2(3, 4)
fmt.Println(r1, r2, r3, r4)
}
//返回一个返回值
func sum(a , b int) int{
result := a + b
return result
}
//预定义返回值的名字
func sum2(a, b int) (sum int) {
sum= a + b
return
}
/*多个返回值*/
func Cale(a,b int)(int,int,int,int) {
he := a + b
cha := a - b
ji := a * b
shang := a / b
return he,cha,ji,shang
}
/*多个返回值+预定义返回值名称*/
func Cale2(a,b int)(he int,cha int,ji int,shang int) {
he = a + b
cha = a - b
ji = a * b
shang = a / b
return
}
网友评论