ANONYMOUS wrote:
> How can we determine when a function body should end if not every function requires a return statement?
>
> The sample code with no return in the function body happens to end with a print statement, is this the only alternative to a return statement for ending a function body? Even so, how are we meant to determine this if multiple print statements are used within one function? (unless there has been a clarification I missed stating that only one print statement is permitted per function, apologies if so)
>
> Thanks
There are no guarantees what the last statement in a function will be, it could return, it could print, or it could be another statement (the syntax of ml allows this). So, relying on seeing a particular statement to know if the function has ended isn't the right approach.
The function ends when indentation ends. E.g. if the last line you saw had an indent, and the current line you are examining doesn't, then the function has ended.