Created
December 4, 2019 02:03
-
-
Save dsibinski/62f21a6a9e62af732b28fceec1310f9c to your computer and use it in GitHub Desktop.
Dart - sample app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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