dart-lang / dart-lang/language
Short form field expressions
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
```dart
class User {
String name;
int age;
String? bestFriend;
User({required this.name, required this.age, this.bestFriend});
bool get canVote => age >= 18;
}
void main() {
var john = User(name: 'John Doe', age: 19, bestFriend: 'Mary');
var mary = User(name: 'Mary Smith', age: 17);
var users = [john, mary];
// Long form
var names = users.map((user) => user.name);
var canVote = users.where((user) => user.canVote);
var hasBestFriend = users.where((user) => user.bestFriend != null);
// Short form
var names = users.map(.name);
var canVote = users.where(.canVote);
var bestFriends = users.map(.bestFriend); // compile-time error because it's nullable? Use long form instead?
}
```
Contributor guide
Research direction
Start with the Dart examples in the issue, comparing the long and proposed short forms for map and where calls. Clarify whether nullable member expressions such as .bestFriend are permitted and define the type-inference and error behavior; done means the language semantics and supported cases are specified.
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
- Mostly clear
- Newbie friendliness
- 25/100