xxxxxxxxxx
class Person {
final String name;
Person(this.name);
Family operator +(Person other) {
return Family([this, other]);
}
@override
String toString(){
return name;
}
}
class Family {
final List<Person> people;
Family(this.people);
@override
String toString(){
return "Family of ${people.length}: ${people.toString()}";
}
}
void main() {
Person dad = Person("Jhonny");
Person mom = Person("Angela");
Family theFamily = dad + mom;
print(theFamily);
//OUTPUT: Family of 2: [Jhonny, Angela]
}