coding style – The cases where returning Bools as literal expressions is a better option


Most people would return Bools as follows:

bananas(color) {
    return (color = "yellow")
}

and not as literal expressions; that is, not this way:

bananas(color) {
    if (color = "yellow")
        return true
    else
        return false
}

However, in the discussion at wiki.c2.com Jim Perry said that if a method involve complex logic, the latter approach might be better.

In more realistic contexts the coder might well anticipate that the isBigger method might eventually involve more complex logic than a simple compare of two variables.

Could you provide an example of what he talked about?

The only thing which came to my mind is something like this:

somefunction(...) {
    // you need to read the whole line to figure out
    // that the return value is Bool.
    // But it won't take much time (about 2 seconds, I suppose), 
    // and so I don't think this is what Jim mean.
    return (var1 = "foo" && var2 = "bar" && var3 > var4)
}
somefunction(...) {
    // you don't need to read the whole line to figure out
    // that the return value is Bool.
    if (var1 = "foo" && var2 = "bar" && var3 > var4)
        return true
    else
        return false
}