Skip to content

Commit

Permalink
docs: add iter error
Browse files Browse the repository at this point in the history
  • Loading branch information
Syuparn committed Dec 10, 2023
1 parent 6ef8d6e commit df0123c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/reference/iterator.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ it2.next # 1
it2.next # 2
```

If you got a `NameErr` from `Iter#next`, you may forget to set an initial value by `new`.

```pangaea
it := <{|i| yield i; recur i+1}>
it.next # NameErr: name `i` is not defined
```

## Why is iterator designed as a stateful function?

There were 2 more ideas to realize iterators, but they required more syntactic elements than the current design.
Expand Down

0 comments on commit df0123c

Please sign in to comment.