Go code
func dimensions() (width int, height int) {
width = 640
height = 480
return
}
fmt.Println(dimensions())Line-by-line explanation
- Width and height are named results.
- The body assigns them.
- Bare return sends the named values.
- The call receives both.
Expected output
640 480This is the expected result.
Named returns can document short functions, but bare returns become confusing in long functions. Explicit returns are often clearer.