ballerina-lang
ballerina-lang copied to clipboard
[Refactoring] Replace normal switches with enhanced switch expressions
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