Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-45315 Drop JDK 8/11 and make JDK 17 by default
  3. SPARK-45515

Use enhanced `switch` expressions to replace the regular `switch` statement

    XMLWordPrintableJSON

Details

    Description

      refer to JEP 361 

       

      Example:

      double getPrice(String fruit) {
        switch (fruit) {
          case "Apple":
            return 1.0;
          case "Orange":
            return 1.5;
          case "Mango":
            return 2.0;
          default:
            throw new IllegalArgumentException();
         }
       } 

      Can be changed to 

      double getPrice(String fruit) {
          return switch (fruit) {
            case "Apple" -> 1.0;
            case "Orange" -> 1.5;
            case "Mango" -> 2.0;
            default -> throw new IllegalArgumentException();
          };
      } 

       

      Attachments

        Activity

          People

            LuciferYang Yang Jie
            LuciferYang Yang Jie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: