The fact is that some people do this (i.e., perform a function as part of an assessment of a condition). This makes sense in a shell script, but if you are not using a shell script, it is sometimes unclear what value is returned for some functions. I could not tell you that the message cout <"message" is being returned from hand to hand, but I know that if you write it inside the body of the loop, it will do what I want and it will "throw out" the return value if I do not use it.
To write cleaner code that others, including your future self, can understand, I would only evaluate conditions that explicitly return true / false, rather than â0 / not-0â or â0/1,â which may differ in different languages.
Bottom line: let the compiler make things more efficient for you and the code for other people, not the compiler.
source share