0
Return method
In the given example, why is it used return? Why not just getting the sum of the two variables straight forward? I don’t get its usage :(
2 Respostas
+ 1
Can you show us the given example? The Q&A section does not link back to the lessons directly.
+ 2
I believe that the example is part of a lesson.
The answer to the question is the branch to the statement and the subsequent return is to illustrate the concept. To directly answer your question. The statement is branched to inorder to manipulate the data. The value of the variable s are assumed to have been changed prior to the execution of the statement in the branch. Once the new manipulation is done return is used to literally return execution to the proper point where the new values will be used.
Having had prior experience with the concept eliminated confusion for myself, yet should not be the expected result. The lesson example should be made more verbose.
I hope that this helps you.
Feel free to msg me if you have need for a better explanation.