dart-lang / dart-lang/language

Can we expect 'switch' operator rework?

Open
#745 1 comment 2 reactions 0 assignees View on GitHub
request
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

I hope Dart devs will add range of values and range checking in switch/case operators - check if value is in range, check array elements, check multiple variables with same switch operator.

For example:

```
int i=27;
switch (i) {
case 1..30:
break;
default:
}

List a=[1,5,7,14,25,30];
switch (a) {
case a.contains(5):
break;
case a[1..4]>0:
break;
}

switch ([a,i] /*(or just a,i)*/ ) {
case i==5:
case a[1..4]>0:
break;
case a[i] !=0:
break;
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the proposed switch examples and the requested capabilities: value ranges, range checks, collection checks, and matching multiple variables. The issue names no files or tests, so research would need to identify the relevant Dart language specification area and establish which syntax and semantics are acceptable before implementation; done means a decided, specified language change.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.