GO语言-命名返回值
发布时间:2020-12-16 19:02:21 所属栏目:大数据 来源:网络整理
导读:GO语言-命名返回值 GO语言-学习笔记 /** * Created with IntelliJ IDEA. * User: liaojie * Date: 12-9-6 * Time: 下午8:33 * To change this template use File | Settings | File Templates. * Name:命名返回值 */package mainimport ("fmt")//命名返回
GO语言-命名返回值 GO语言-学习笔记 /** * Created with IntelliJ IDEA. * User: liaojie * Date: 12-9-6 * Time: 下午8:33 * To change this template use File | Settings | File Templates. * Name:命名返回值 */ package main import ( "fmt" ) //命名返回值 //nextInt 将返回两个int值 func nextInt(b []byte,pos int) (value,nextPos int) { value,nextPos = pos,pos return } //nextInt2 将返回第一个byte,第二个int值 func nextInt2(b []byte,pos int) (value []byte,nextPos = b,pos return } func main() { fmt.Println(nextInt([]byte ("123"),2)) fmt.Println(nextInt2([]byte ("123"),2)) a,b := nextInt2([]byte ("123"),2) fmt.Println(a) fmt.Println(b) } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |