You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classUser {
String name;
int age;
String? bestFriend;
User({requiredthis.name, requiredthis.age, this.bestFriend});
boolget canVote => age >=18;
}
voidmain() {
var john =User(name:'John Doe', age:19, bestFriend:'Mary');
var mary =User(name:'Mary Smith', age:17);
var users = [john, mary];
// Long formvar names = users.map((user) => user.name);
var canVote = users.where((user) => user.canVote);
var hasBestFriend = users.where((user) => user.bestFriend !=null);
// Short formvar 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?
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: