首页 > 代码库 > A Tour of Go Multiple results

A Tour of Go Multiple results

A function can return any number of results.

This function returns two strings.

package mainimport "fmt"func swap(x, y string) (string, string) {    return y, x}func main() {    a, b := swap("hello", "world")    fmt.Println(a, b)}

 

A Tour of Go Multiple results