Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Go return multiple values

Shulou Source: shulou.com Published: 2022-06-01 02:31:42 09月28日 Update

This article mainly explains "how Go returns multiple values". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how Go returns multiple values".

Function returns multiple values

The Go function can return multiple values, such as:

Example

Package main

Import "fmt"

Func swap (x, y string) (string, string) {

Return y, x

}

Func main () {

A, b: = swap ("Google", "Runoob")

Fmt.Println (a, b)

}

The execution result of the above example is:

Runoob Google thank you for reading, the above is the content of "how Go returns multiple values". After the study of this article, I believe you have a deeper understanding of how Go returns multiple values, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Multiple learning content functions examples that is ideas situations articles more knowledge knowledge points articles results follow problems practice push research verification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia Shulou Tech Info Linux Shulou Technology