August 2019
Beginner to intermediate
798 pages
17h 2m
English
Unlike C, Go allows you to name the return values of a Go function. Additionally, when such a function has a return statement without any arguments, then the function automatically returns the current value of each named return value in the order in which it was declared in the definition of the function.
The source code that illustrates Go functions that have named return values is returnNames.go, and it will be presented in three parts.
The first part of the returnNames.go program is as follows:
package main
import (
"fmt"
"os"
"strconv"
)
func namedMinMax(x, y int) (min, max int) {
if x > y {
min = y
max = x
} else {
min = x
max = y
}
return
}
In this code segment, you can see the implementation ...
Read now
Unlock full access