Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created December 4, 2019 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsibinski/62f21a6a9e62af732b28fceec1310f9c to your computer and use it in GitHub Desktop.
Save dsibinski/62f21a6a9e62af732b28fceec1310f9c to your computer and use it in GitHub Desktop.
Dart - sample app
main() {
var myCar = new Car("Cybertruck", new DateTime(2021, 01, 01));
myCar.describe();
}
class Car {
String model;
DateTime productionDate;
// Ctor: notice the syntactic sugar members' assignment
Car(this.model, this.productionDate) {
// Some other ctor init code here
}
int get productionYear =>
productionDate?.year;
void describe() {
print('Car: $model, produced in $productionYear');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment