GolangGo funcint8int16/int32
int8int16int32
package main
import (
"fmt"
)
func Arithmetic(a,b int8) (int8,string,int16,int32){
return a-b, "add",a*b,a/b
}
func main() {
a,b,c,d :=Arithmetic(5,10)
fmt.Println(a,b,c,d)
}
错误:
C:/Go\bin\go.exe run C:/GoWorkspace/src/tlesource/ff.go
# command-line-arguments
.\ff.go:15: cannot use a * b (type int8) as type int16 in return argument
.\ff.go:15: cannot use a / b (type int8) as type int32 in return argument
Process finished with exit code 2