28
rsync
18d

Seriously, I want to shoot the dev that did this. Who puts double !! it just negates each other -- not not true is true!!! FUCK!!!!

Comments
  • 1
    do u work at pp
  • 3
    What... The... Fuck....
  • 8
    In JS it’s useful for some truthy-falsey stuff but idk in php
  • 8
    Coerce Boolean?
  • 10
    But clearly:
    ! == not
    !! == especially not
    😂
  • 2
    Why did he not use triple equal?
  • 1
  • 14
    !! has good use in C; it basically means "map any non-zero integer to 1 and leave 0 as is".
  • 5
    PHP devs used to do this to turn 'string' into true and '' into false. But now you can just replace it with a (bool) cast, and might as well set strict types.
  • 3
    @JKyll @bittersweet Now I remember why I hate a lot of PHP devs...
  • 2
    At least he's not doing

    if (condition == true)
    ...
  • 2
    @gitpush said it for me!
  • 2
    As everyone else already said, its used mainly to explicitly coerce strings (or other values) into a boolean true/false

    Most dev teams use it for readability. It reads:

    "If something EXISTS" and it shows other devs that we dont care for the value, just its existence.

    So before killing someone, always ask yourself first "what if they do it for some reason im not aware of" :)
  • 0
    Maybe a fullstack dev that started js first before php. That's pretty useful in js. Although personally I would always use 3 equals.
  • 1
    @rsync it just compounds in PHP, but other then this screen shot, I have never seen anyone use !!x over x === y or cast to bool.

    If you aren’t paying attention you would probably skip the !! and read it as !

    the brain has a habit of skipping repeated text.
  • 1
    But I concede it does seem to be legitimate to cast to bool even though not common.
  • 2
    @rsync nope, I’m sticking to setting things as true/false
    this !! Is just going to lead to mass confusion in a project.
  • 2
    @C0D4

    I agree, it obviously led to my confusion.
Your Job Suck?
Get a Better Job
Add Comment