• yetAnotherUser@discuss.tchncs.de
    link
    fedilink
    arrow-up
    20
    ·
    edit-2
    1 month ago

    I dislike the .not() method a bit because it inverts the meaning of the previous code snippet you’ve read.

    if (list.isEmpty()...
    

    “Ah, so if the list is empty…”

    if (list.isEmpty().not())
    

    “Goddammit”

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      6
      ·
      1 month ago

      For me, it’s pretty much the opposite. With the exclamation mark, I’ll see the inversion, then I’ll read the actual condition and try to make sense of it, and then I’ll remember that this thing was supposed to be inverted. Or I won’t remember, that’s unfortunately also a possibility.

      Might just be what we’re used to, though. I have been working in a codebase with mostly .not() for the past year.