Join Nostr
2025-06-03 17:00:59 UTC
in reply to

The gallant knight on Nostr: interestingly iterators and iterable structures behave identically in for loops. So ...

interestingly iterators and iterable structures behave identically in for loops. So iterating over a Set and iterating over a Set.values feels identical:

```
const s = new Set([1,2,3]);
const v = s.values();
for (const x of s) {console.log(x)};
for (const x of v) {console.log(x)};
```
Yet v can only be consumed once. This came up last week because we had a computed on values and it only ever worked once until I spotted the MapIterator that was created.