What does this code output?
class P {
int x = 0;
void add(int n) { x += n; }
}
void main() {
var p = P()
..x = 2
..add(3)
..add(4);
print(p.x);
}
Try it in the online Dart Playground →
[spoiler title="Solution"]
Answer:
9
Explanation:
.. is a cascade operator, which mutates the same instance, so here x goes 2 -> 5 -> 9.
[/spoiler]