Can you return multiple values from a function?

Technology CommunityCategory: GolangCan you return multiple values from a function?
VietMX Staff asked 3 years ago

A Go function can return multiple values.

Consider:

package main
import "fmt"

func swap(x, y string) (string, string) {
   return y, x
}
func main() {
   a, b := swap("Mahesh", "Kumar")
   fmt.Println(a, b)
}