iterator property
Returns an iterator over the sub‑pulses in this pulse.
When to use
- Use this to iterate over the individual pulses in a composite.
- Iterating over the pulses in a collective.
- Processing each pulse in a bundle individually.
- Checking what pulses are in a composite.
How it works
- For a standard or collective pulse: returns an iterator over a single element — the pulse itself.
- For an evolved pulse: returns an iterator over the entire chain.
Non‑obvious: a collective iterates over itself, not its payload
For a CollectivePulse, iterating over the collective yields the collective as a single item, not its constituent pulses. To access the individual pulses, use the payload getter:
for (final p in collective) { } // one item (the collective)
for (final p in collective.payload) { } // all sub‑pulses
Example
final collective = Pulse<int>(1) + Pulse<String>('hello');
for (final p in collective) {
print(p.payload); // Outputs: 1, hello
}
Implementation
@override
Iterator<Pulse> get iterator;