[ 
https://issues.apache.org/jira/browse/SPARK-45515?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot reassigned SPARK-45515:
--------------------------------------

    Assignee: Apache Spark

> Use `Switch Expressions` to replace the regular `switch` statement
> ------------------------------------------------------------------
>
>                 Key: SPARK-45515
>                 URL: https://issues.apache.org/jira/browse/SPARK-45515
>             Project: Spark
>          Issue Type: Sub-task
>          Components: Spark Core, SQL
>    Affects Versions: 4.0.0
>            Reporter: Yang Jie
>            Assignee: Apache Spark
>            Priority: Major
>
> refer to [JEP 361|https://openjdk.org/jeps/361] 
>  
> Example:
> ```java
> double getPrice(String fruit) {
>   // Switch statement can be replaced with enhanced 'switch'
>   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 
> ```java 
>   double getPrice(String fruit) {
>     return switch (fruit) {
>       case "Apple" -> 1.0;
>       case "Orange" -> 1.5;
>       case "Mango" -> 2.0;
>       default -> throw new IllegalArgumentException();
>     };
>   }
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to