• 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?