> For the complete documentation index, see [llms.txt](https://ineelhere.gitbook.io/code-with-go/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ineelhere.gitbook.io/code-with-go/13-multiple-return-values.md).

# Multiple Return Values

This Go program demonstrates the use of a function that returns multiple values.

```go
// Importing the "fmt" package, which provides functions for formatted I/O.
import "fmt"

// Function vals returns two integers (3 and 7).
func vals() (int, int) {
    return 3, 7
}

// The main function, which serves as the entry point for the program.
func main() {
    // Calling the vals function and receiving two return values (a and b).
    a, b := vals()

    // Printing the value of variable 'a'.
    fmt.Println(a)

    // Printing the value of variable 'b'.
    fmt.Println(b)

    // Calling the vals function again, but using the blank identifier "_" to discard the first return value.
    // Only the second return value is assigned to variable 'c'.
    _, c := vals()

    // Printing the value of variable 'c'.
    fmt.Println(c)
}
```

#### Output

```
3
7
7
```

Now, let's break down the code and explain each part:

1. **Function Declaration:**
   * `vals() (int, int)`: This function returns two integers, 3 and 7.
2. **Main Function:**
   * `main()`: This is the entry point of the program.
   * `a, b := vals()`: Calls the `vals` function and receives two return values (3 and 7), which are assigned to variables `a` and `b`.
   * `fmt.Println(a)`: Prints the value of variable `a`.
   * `fmt.Println(b)`: Prints the value of variable `b`.
   * `_, c := vals()`: Calls the `vals` function again, but uses the blank identifier "\_" to discard the first return value. The second return value (7) is assigned to variable `c`.
   * `fmt.Println(c)`: Prints the value of variable `c`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ineelhere.gitbook.io/code-with-go/13-multiple-return-values.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
