Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewackerman/2604a6294ec819f113605d62a610066e to your computer and use it in GitHub Desktop.
Save andrewackerman/2604a6294ec819f113605d62a610066e to your computer and use it in GitHub Desktop.
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