1、代码
2、运行
1、代码
1 package main 2 import ( 3 "fmt" 4 "strconv" 5 ) 6 7 func getValue(n int) (float32, string) { 8 var x float32 = float32(n) 9 var str string = strconv.Itoa(n) 10 return x, str 11 } 12 13 func main(){ 14 var n int = 10; 15 16 x, str := getValue(n) 17 18 fmt.Printf("x = %f\nstr = %s\n", x, str) 19 }
2、运行
$ go run multireturns.go x = 10.000000 str = 10
有疑问加站长微信联系(非本文作者)