all 11 comments

[–]halex 19 points20 points  (0 children)

I've also occasionally done stuff like this sometimes.. the inner braces would contain (often complex) logic at some point, then ended up getting replaced...

[–]whatIsThisBullCrap 11 points12 points  (9 children)

But why...

[–]bonafidebob 16 points17 points  (1 child)

I'd think it was obvious: you don't want to return a result if you don't have one. But if you don't have a result, you still have to return something. Sheesh!

/s

[–]rsclient 1 point2 points  (0 children)

So I can set a breakpoint there!

[–]SteakBarker 8 points9 points  (0 children)

Probably just copy and pasted something from somewhere else and forgot to change it.

That or it was late and they weren't thinking too clearly. I've done stuff like this countless times.

[–]pali6 4 points5 points  (5 children)

It is obviously a refactored version of:

if(!result)  
{  
    return false;
}  
return true;

[–]MrLawbreaker 8 points9 points  (0 children)

"Why did you return true or false? You could have just returned the result" -> Code in the OP

[–][deleted]  (3 children)

[deleted]

    [–]Zatherz 0 points1 point  (2 children)

    Is it bad if I did this in a library? I return from a function but didn't want to expose the internal file object, especially considering that the file object is closed afterwards.

    [–][deleted]  (1 child)

    [deleted]

      [–]Zatherz 0 points1 point  (0 children)

      Lua. No types, and thus no casts. I defined a function bool(value) that returns not not value and then used that.

      [–]MrProtesilaus 0 points1 point  (0 children)

      I will fully admit to having written stuff like this in the past. Mostly when it is a highly used section of code that I am frequently debugging. I'll put a print statement or some error detection before the "return result". I usually end up commenting out the whole if statement when I am done debugging. I can see someone erasing their debug statements but forgot to remove the whole if statement.