Thanks to some useful input from @satikusala I’ve been able to add some clarifications in aTbRef about returning data from a function and how it is accessed. Whilst blindly obvious for those with coding training, it may be less so to others. I’ve thus added a more explicit explanation about the need to use a receiving attribute or variable when calling a function that has a return value.
I’ve thus updated the articles for Returning function values and Calling functions to reflect this.
TL;DR? Well, if a function fTest() returns the string “Hello”, this valid code will call the function:
fTest();
…but importantly, the returned value is lost unless there is a left-side object such as an attribute or variable to receive it:
$MyString = fTest();
Thus, $MyString now holds the returned value Hello
. The exact data type on the left will depend on the function called and the overall context. The key point is if you expect a return you much set something to hold the called function’s return operator value.