package main
import (
"fmt"
)
func riskyParams() (num int, flag bool) {
if num == 0 { // Named parameters have default values in the scope
flag = true
}
return // Beware of such return. You might return something unintended
}
func main() {
num, flag := riskyParams()
fmt.Printf("num=%d flag=%v\n", num, flag)
}
The example highlights unintended side-effects of named return parameters.
Written with StackEdit.