It's UWAweek 47

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 828 articles.
Currently 24 other people reading this forum.


 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported

Login to reply

👍?
helpful
7:59am Thu 5th Sep, Joshua N.

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.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy