Skip to content

Instantly share code, notes, and snippets.

@Wassmd
Created September 23, 2019 11:19
Show Gist options
  • Save Wassmd/96bce9aed0b01c5e6346acc86c6be951 to your computer and use it in GitHub Desktop.
Save Wassmd/96bce9aed0b01c5e6346acc86c6be951 to your computer and use it in GitHub Desktop.
void main() {
// Methods
int result = calculator(1,2, multiply);
print(result);
// Class
Car lumbargini = Car(drive: driveFast);
lumbargini.drive = driveSlow;
lumbargini.drive();
}
final Function calculator = (int n1, int n2, Function calculation) {
return calculation(n1, n2);
};
int add(int n1, int n2) {
return n1 + n2;
}
int multiply(int n1, int n2) {
return n1 * n2;
}
class Car {
Car({this.drive});
Function drive;
}
void driveSlow() {
print('drive slow');
}
void driveFast() {
print('drive fast');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment