Statement
Named function results
Named results are local variables initially zero. An empty return uses their current values. Deferred calls may modify named results before the caller receives them. Example output: '5'.
Formal Syntax & Structure
go syntaxgo
func f() (result T) { ...; return }Working Example
Example Snippetgo
package main
import "fmt"
func score() (n int) { n = 4; defer func() { n++ }(); return }func main() { fmt.Println(score())}