• floofloof@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 month ago

    Another old programmer here, and I don’t see the issue. C# gets better with every release and the null coalescing assignment operator is very handy. It also exists in JavaScript.

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

      Ruby has it as well:

      a ||= b
      
      # which means
      a = a || b
      # wich is the same as
      a = b if !a
      # which rubyists like to write as
      a = b unless a
      # or as ternary
      a = a ? a : b
      
      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 month ago

        That’s way too many ways of doing the same thing, yuck.

        But you’re saying the idiomatic way is to use unless, rather than the actual operator for this?

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

      I feel like it boils down to understanding that operator. I’m a TypeScript developer by trade so I had no issue understanding this. 🤷‍♂️