Go multiple return values

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

The go language has revolutionized the ability to provide multiple return values in the static development language camp. This feature allows developers to free themselves from the pain of returning multiple values in a variety of awkward ways, without having to differentiate which of the parameter lists to use for input, which are used for output, or to specifically define a data structure just to return multiple values.

Package <textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">Mainimport "FMT" func vals (int, int) {return 3, 7}func main () {A, B: = Vals () fmt. Println (a) fmt. Println (b) _, C: = Vals () fmt. Println (c)}</textarea>
123456789101112131415 Package MainImport "FMT"funcVals() (int, int) {    return 3, 7}funcMain() {    a, b := Vals()    FMT.Println(a)    FMT.Println(b)    _, C := Vals()    FMT.Println(C)}

Package <textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">main Import "FMT" func split (sum int) (x, y int) {x = sum * 4/9 y = sum-x return} func main () { Fmt. Println (split)}</textarea>
12345678910111213 Package Main Import "FMT" funcSplit(sumint) (x, y int) {    x = sum * 4/9    y = sum - x    return} funcMain() {    FMT.Println(Split( -))}

go multiple return values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.