Created
November 25, 2019 23:09
-
-
Save r3dm1ke/6146f4855d02ed944a4cfd564c83c129 to your computer and use it in GitHub Desktop.
Class definitions in Dart
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
class Computer { | |
String hostname; | |
int numberOfCores; | |
// Syntactic sugar for instance variable assignment | |
Computer(this.hostname, this.numberOfCores) { | |
// Some initialization code | |
} | |
void ping() { | |
print('Pong from $hostname'); | |
} | |
} | |
void main() { | |
var comp = new Computer('localhost', 4); | |
comp.ping(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment