Created
June 14, 2019 22:37
-
-
Save andrewackerman/2604a6294ec819f113605d62a610066e 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
typedef T2 Adder<T1, T2>(T1 left, T1 right); | |
class AddMachine<A> { | |
A left; | |
A right; | |
AddMachine(this.left, this.right); | |
B Sum<B>(Adder<A, B> adder) { | |
print([A, B]); | |
print(adder.runtimeType); | |
return adder(left, right); | |
} | |
} | |
void main() { | |
var a = 1; | |
var b = 2; | |
var machine = AddMachine(a, b); | |
var result = machine.Sum((a, b) => a.toString() + b.toString()); | |
print(result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment