• rtxn@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    And that improves readability, how? Don’t get me wrong, I’m a big fan of the Elvis operator, but chaining multiple null coalescing assignments into a one-line expression is a chore to decipher.

    By the way, you forgot to return the result.

    • masterspace@lemmy.ca
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      And that improves readability, how?

      Because null checks are an extremely common operation to have to do, and this let’s your code read as just the business logic without these constant null checks breaking things up by multiple lines.

      It’s only not readable to you because you’re not used to them. That’s the case for literally every bit of new programming syntax that comes along.

    • Victor@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 month ago

      you forgot to return the result.

      What result? The result is A being assigned a value. That’s the result.