Skip to content

Instantly share code, notes, and snippets.

@mit-mit
Last active December 13, 2019 18:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mit-mit/c210bfb088545e69ba9231ee459615ba to your computer and use it in GitHub Desktop.
Save mit-mit/c210bfb088545e69ba9231ee459615ba to your computer and use it in GitHub Desktop.
void main() {
Person('Larry', birthday: DateTime(1973, 03, 26)).describe();
Person('Sergey').describe();
}
class Person {
String firstName;
DateTime? birthday;
Person(this.firstName, {this.birthday});
void describe() {
print(firstName);
int? birthyear = birthday?.year;
if (birthyear != null) {
print('Born ${DateTime.now().year - birthyear} years ago');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment