# What are the pros and cons of these two coding patterns/structures? And do they have a formal term?

I have traditionally been doing things like this:

function test() // A
{
if (/* conditions */)
return true;
else
return false;
}


Of late, I have instead starting doing, and converting existing code like the example above, into this:

function test() // B
{
if (/* conditions */)
return true;

return false;
}


I can see arguments for both ways, but the "new" way (to me) seems to win after all. I used to not "parse" code correctly in my head, so I thought that it could sometimes continue executing the code in a function after a "return" has been encountered, which is not actually the case in reality. At least I think (and hope) so...

I'm interested in hearing objective arguments for/against what we can call "A" or "B" for simplicity.

• Look at the “guard” statement in Swift and think when you would use it. – gnasher729 Nov 26 '19 at 16:48
• (Then again, the condition is a boolean - just return condition;) – greybeard Nov 26 '19 at 17:05