+ 3

Anyone can explain the Return?

In C# and lua(and others languages) have a expression (i guess) called "return", used at the end of funcions, can someone explain it to me in more detail please?

15th Dec 2019, 9:26 PM
Sneazy Br
Sneazy Br - avatar
4 Antworten
+ 7
There's a thing called function or method (not exactly the same, but comparable). They are pieces of code that are separated from the rest of your code and don't have access to the values you have in the place from where you call the function, and this place also can't reach the inside of the function. So if the function needs to 'know' something to do it's work, you have to hand it over, like in an 'envelope'. And if the function is supposed to calculate a result for the caller, then it has to 'give it back' in another envelope. That's what return does: It transfers a value from the function body right back to the point where the function was called.
15th Dec 2019, 9:37 PM
HonFu
HonFu - avatar
15th Dec 2019, 9:42 PM
sneeze
sneeze - avatar