ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Refactoring] Replace normal switches with enhanced switch expressions

Open f-schnabel opened this issue 1 year ago • 1 comments

Purpose

Many existing switch statements are essentially simulations of switch expressions, where each arm either assigns to a common target variable or returns a value. Expressing this as a statement is roundabout, repetitive, and error-prone.

Java 14 added support for switch expressions, which provide more succinct and less error-prone version of switch. See also: https://sonarcloud.io/organizations/ballerina-platform/rules?languages=java&open=java%3AS5194&q=switch+expression Partly also fixes: https://sonarcloud.io/organizations/ballerina-platform/rules?open=java%3AS6208&rule_key=java%3AS6208

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [ ] Added necessary tests
    • [ ] Unit Tests
    • [ ] Spec Conformance Tests
    • [ ] Integration Tests
    • [ ] Ballerina By Example Tests
  • [ ] Increased Test Coverage
  • [ ] Added necessary documentation
    • [ ] API documentation
    • [ ] Module documentation in Module.md files
    • [ ] Ballerina By Examples

f-schnabel avatar Jun 19 '24 21:06 f-schnabel