Created
September 23, 2019 11:19
-
-
Save Wassmd/96bce9aed0b01c5e6346acc86c6be951 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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