42

Fond this gem in a sample code at uni...
Noice 👌👌👌

Comments
  • 5
    Return t.result() 🤷‍♂️
  • 15
    t.result() > 0 ? true : truen't
  • 4
    @C0D4 nope not that way.
    I've seen people fucking using that true value as 1 for operations

    You never know the code is bad at just one line or it is the start of a horrendous journey
  • 0
    Well it could be worse, they could be numbers or strings.

    I think this is a nice way to learn this operator.
  • 1
    It depends on how much the programming laguage is typed. Javascript or php would be so different from java or c++ in interpreting this line of code.

    Like sometime ppl write stuff like :
    If(var) {}

    So if var is null it is assumed as false. I see this so much in javascript when devs avoid trying to understand the differences between, null, undefined, false, nan lol.
  • 0
    @devapsarl Even then, `value!!` is fine
  • 1
    I remember back in school some people actually wrote code like this:

    if(list.isEmpty()) {

    return true;

    }

    else {

    return false;

    }
  • 2
    @C0D4 oh and btw -1 is treated as true in most of the languages in case the return type as Boolean
  • 0
    return t.result() > 0;

    Could use the raw value, but I like to keep my types consistent...
  • 2
    if (true) return !0; else return !1;
  • 2
    Found sample code at uni??

    Son, similar trash in prod for (at least) 3 years.
Add Comment