Skip to content

Instantly share code, notes, and snippets.

@ialameh
Last active June 30, 2020 22:53
Show Gist options
  • Save ialameh/7be9752c8316fdf38694725925128592 to your computer and use it in GitHub Desktop.
Save ialameh/7be9752c8316fdf38694725925128592 to your computer and use it in GitHub Desktop.
void main() {
Map<Calc, List<Calc>> map = {};
Calc calc = new Calc(5);
Calc calc1 = new Calc(6);
Calc calc2 = new Calc(7);
calc.add(11, 12);
map[calc] = [calc1, calc2];
map[calc][0].add(1, 2);
map[calc][1].add(6, 7);
print(map[calc][0].sum);
print(map[calc][1].sum);
print(calc.sum);
print(calc1.sum);
print(calc2.sum);
print(map.keys.toList()[0].sum);
}
class Calc {
int _sum;
Calc(_sum);
add(int a, int b) {
_sum = a + b;
}
get sum => _sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment