@pathmaker-digital/pmd-utilities - v2.2.6
    Preparing search index...

    Function proSwitchReturn

    • Similar to a match expression in languages like Rust.

      Type Parameters

      • T
      • R

      Parameters

      Returns undefined | R

      A value if a match was found.

      const result = proSwitchReturn("green", [
      { value: "red", operation: () => "You chose red" },
      { value: "blue", operation: () => "You chose blue" },
      { default: true, operation: () => "Color not recognized" },
      ]);

      console.log(result); // "Color not recognized"