45

What the fuck is this. I swear every time I look at this codebase I find something more stupid than I did last time.

I can't wait to throw the whole legacy system away.

Comments
  • 2
    Gotta love that compression too
  • 1
    $mode || $mode = '0';
  • 1
    @Root $mode = $mode ?: 'defaultlang';
  • 3
    @ThatDannyBoy I prefer perl-like syntax 😋
  • 4
    @JustThat in php '0' is falsely so the second statement is always called after the first one.
  • 1
    @ThatDannyBoy Bloody hell I forgot about how infuriating and unintuitive php is.
  • 1
    @Root How is that unintuitive? Isn't that just a standard rule for languages without direct datatypes?
  • 1
    @PrivateGER in Perl '0' would be evaluated as true.

    I prefer Perl syntax, too.

    $mode or $mode = "defaultlang";

    just looks nicer than the ternary operator with omitted second operand.
    But that's a matter of taste, of course. I bet many people would prefer :? ...
  • 4
    @PrivateGER A non-empty string being falsey is unintuitive. Honestly, in typed languages I would prefer if nothing but false and null/undefined evaluate to false. Fewer accidental errors and unexpected behavior that way.
  • 2
    @PrivateGER Strings shouldn't cast to anything automatically IMO. Especially not on the server side. Manual casts don't bite, mixing input with runtime values does. For example by enforcing a cast maybe devs wouldn't forget to check for range of input numbers. In the past month I used 3 different websites that allowed buying -1.5 t-shirts
  • 5
    If that's the worst code in your legacy system then it sounds like you have a pretty cushy job
  • 1
    💯 my favorite kind of code
  • 0
    $mode = $mode ?? 'defaultlang';
Add Comment