A Tour of Go Multiple results

A function can return any number of results.

This function returns two strings.

package main

import "fmt"

func swap(x, y string) (string, string) {
    return y, x
}

func main() {
    a, b := swap("hello", "world")
    fmt.Println(a, b)
}

 

posted @ 2014-10-26 19:47  wuhn  阅读(145)  评论(0编辑  收藏  举报