Very common mistakes with parameter passing, continued
- While not an example of an error,
you will sometimes see code such as:
return x;
and sometimes:
return(x);
While both are correct, the parentheses in the 2nd example are unnecessary.
return is not a function call, it is a statement,
and so does not need parentheses around the returned value.
However - at any point when writing code,
use extra parentheses if they enhance the readability of your code.
CITS2002 Systems Programming, Lecture 4, p9, 31st July 2024.
|