116

I was suppose to review this code.

if (null != value) {
return value;
} else {
return null;
}

Comments
  • 13
    That's deep. Or shallow.
  • 8
    I mean, it kind of makes sense. It shows, that getting null here is an expected behavior, but it's a special case that needs to be handled separately.

    Expressing intent is much more important than brevity.
  • 7
    (value == null) ? return null : return value;

    There you go.
  • 25
    @beggarboy how about return value; ? #smh
  • 5
    Are the lines all aligned because that's how the programmer did it, or because you did it because that's easier than aligning them on the phone for ranting?
  • 3
    @QueenMorgana hope the latter
  • 5
    @olezhka That's why I'm asking. I really hope it's the latter
  • 12
    I can't believe there's even a discussion about this.
  • 7
    @sSam I can't belive i read the discussion till the end.
  • 1
  • 4
    I understand that this is a silly block of code that could've just been "return value;", but the "if (null != value)" just makes so irrationally angry. Make it "if (value == null)".
  • 3
    @beggarboy if you want to use the ternary operator in a return statement, at least do it properly:
    return value == null ? null : value

    But @olezhka is right, just write return value;
  • 1
    Wtf, I’m so confused
Add Comment