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) }