Go Function return types with names

Introduction

We can name the return type like this:

func f2() (r int) { 
    r = 1 
    return 
} 

package main/*from w w  w  .j av a2 s  .c o m*/

import "fmt" 

func main() { 
   fmt.Println(f2()) 

}

func f2() (r int) { 
    r = 1 
    return 
} 



PreviousNext

Related