Learn Go passing variable-length arguments

Source: Internet
Author: User

Package Main//Reference Documentation://     https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/06.3.mdImport"FMT"Func Main () {x:= Min (1,3,2,0) fmt. Printf ("The mininum is:%d\n", X)//parameter is stored in an array of arr, you can pass the parameter call argument function in the form of arr .... Arr: = []int{7,9,3,5,1} x=min (arr ...) Fmt. Printf ("The mininum in the arr is:%d\n", X)} Func min (A ...int)int {    ifLen (a) = =0 {        return 0} min:= a[0]     for_, V: =Range A {ifV <min {min=v}}returnmin}

Learn Go passing variable-length arguments

Related Article

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.