Overview - Return values
What is it?
Return values are the results that a function sends back after it finishes running. In Go, functions can send back one or more values to the place where they were called. These values can be simple like numbers or text, or more complex like lists or custom data types. Return values let functions share their results so other parts of the program can use them.
Why it matters
Without return values, functions would only do work inside themselves without sharing results, making it hard to build programs that solve problems step-by-step. Return values let us break big tasks into smaller pieces, each giving back answers that the next piece can use. This makes programs easier to understand, test, and fix.
Where it fits
Before learning return values, you should know how to write and call basic functions in Go. After mastering return values, you can learn about error handling with multiple returns, named return values, and how to use return values in more complex patterns like interfaces and goroutines.