You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Yang Jie (Jira)" <ji...@apache.org> on 2023/10/13 00:50:00 UTC

[jira] [Resolved] (SPARK-45515) Use enhanced `switch` expressions to replace the regular `switch` statement

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

Yang Jie resolved SPARK-45515.
------------------------------
    Fix Version/s: 4.0.0
       Resolution: Fixed

Issue resolved by pull request 43349
[https://github.com/apache/spark/pull/43349]

> Use enhanced `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: Yang Jie
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>
> refer to [JEP 361|https://openjdk.org/jeps/361] 
>  
> Example:
> {code:java}
> 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();
>    }
>  } {code}
> Can be changed to 
> {code:java}
> double getPrice(String fruit) {
>     return switch (fruit) {
>       case "Apple" -> 1.0;
>       case "Orange" -> 1.5;
>       case "Mango" -> 2.0;
>       default -> throw new IllegalArgumentException();
>     };
> } {code}
>  



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

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