Fiveable
Fiveable

return

Definition

The return keyword is used in functions/methods to send back a value to the caller. It terminates the execution of a function and passes control back to where it was called from.

Analogy

Imagine going to a vending machine and inserting money to buy a snack. Once you make your selection, the machine returns your chosen snack (value) and ends its operation, allowing you to continue with whatever you were doing before.

Related terms

Void method/function: A void method or function does not return any value. It performs some actions but doesn't send anything back.

Return type: The return type specifies what type of value will be returned by a function/method.

Method call/invocation: A method call refers to using/calling a specific method in your program, which may include passing arguments and receiving returned values.

"return" appears in:

Practice Questions (19)

collegeable - rocket pep

Are you a college student?

  • Study guides for the entire semester

  • 200k practice questions

  • Glossary of 50k key terms - memorize important vocab



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.