Overview - Return values
What is it?
Return values are the results that a function sends back to the part of the program that called it. When a function finishes its work, it can give back a value like a number, text, or even a complex object. This lets the program use the function's result for further actions. Without return values, functions would only do tasks without sharing their outcomes.
Why it matters
Return values let programs be more flexible and powerful by allowing functions to produce results that other parts of the program can use. Without return values, you would have to repeat code or rely on less clear ways to share information, making programs harder to write and understand. Return values help keep code organized and reusable, saving time and reducing mistakes.
Where it fits
Before learning return values, you should understand what functions are and how to call them. After mastering return values, you can learn about advanced topics like function overloading, recursion, and how to return complex data types or references.