Return values: the answer a function gives back
A return value is the answer a function sends back to the code that called it. Your program can save that answer, calculate with it, compare it, or display it.
# language: en
function double(value):
return value * 2
let answer = double(6)
say answer + 1
double(6) returns twelve. The program stores twelve in answer, then prints thirteen.
Returning is different from displaying
say puts text in the output. return gives a value to the caller. A function can display a message without returning that message. If you want to use the result in another calculation, returning it is useful.
In Pliro, return also ends the current function call. Instructions after it on that path are skipped. It does not stop every other part of the application; exitApp has that different job.
A function that reaches its end without returning a value produces none. A bare return also gives none. This is Pliro’s “no value,” not zero and not empty text.
Read a reference page
A built-in’s Returns or Return value section tells you what kind of answer to expect. length returns a Number. A drawing command may return None while still producing a visible effect.
Try saving double(3) and using it twice. How many times must the function run?
