Go 함수 여러 건 반환

1 개요[ | ]

Go Multiple results
Go 함수 여러 건 반환
  • Go에서는 여러 건을 반환하는 함수를 작성하는 경우가 매우 흔하다.
  • 특히 결과 변수 1개, error 변수 1개를 반환하는 경우가 많다.
package main

import "fmt"

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

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

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}