Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Created November 25, 2019 23:09
Show Gist options
  • Save r3dm1ke/6146f4855d02ed944a4cfd564c83c129 to your computer and use it in GitHub Desktop.
Save r3dm1ke/6146f4855d02ed944a4cfd564c83c129 to your computer and use it in GitHub Desktop.
Class definitions in Dart
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