dart-lang / dart-lang/language
Statements inside if conditions
Open
feature
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Statements inside control statement conditions to store it, check it and also scope it inside the control statement block would be very useful.
```dart
if((Point point = parseCursorPosition(chars)) != null) {
// Do something with point
}
```
or
```dart
if(Point point = parseCursorPosition(chars); point != null) {
// Do something with point
}
```
This feature is very popular in golang world.
Right now, this is possible:
```dart
Point point;
if((point = parseCursorPosition(chars)) != null) {
// Do something with point
}
```
The only problem is this leaks the point outside its scope.
Contributor guide
Assessment
This issue has not been assessed yet.