Mathematics defines a function as something that returns something upon some input. For us, the programmers, it is not just so… what we call function, in C family of programming languages, is rather a procedure from our perspective.C like languages have a rule that, a function must have a return type, and many internal implementation of different platforms depends upon them; and these return types are not always just void, so you might have to return something. But, as a matter of fact, these return values don’t mean anything in many cases. Many function always return the same value, just a success code or Boolean true or something like that. So, programmers overlook its importance or even existence while dealing with such numb functions. So did I today. As a result, i had to dig my head into wall and in vain. What I found at last, that I missed a single last statement, the return – pretty dirty thing 😦
Guess what? this is another Aesop’s fable and the moral of the story is, Never forget a return statement, not even when it is dumb.
Now what? I’m the guy who suggest a lot, so let me pose a suggestion, “write a return statement in the very moment you type the braces of the function; return statement shall be the first code you do in your function”.
Duh, it is enough for now let me log off!