I would like to know your opinion on using return
and else
statements interchangeably in CFScript. I generally use the following syntax:
if (something) {
// Do something
}
else {
// Do something else
}
It recently occurred to me I could do this instead:
if (something) {
// Do something
return;
}
// Do something else
Would those two styles yield a different end result? I like not having to wrap code in an else
statement. My thinking is that if the if
statement evaluates true and returns, the code below it will not run. If it does not evaluate true, then the code below it will run regardless of whether it is wrapped in an else
statement or not.
Does that sound right?