mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
iter: document that calling yield after terminated range loop causes runtime panic
The existing documentation isn't clear about the behaviour of when
the iterator function ignores the value returned from the yield function.
The changes here update the documentation, to explicitly explain
that.
Change-Id: I24a8198c3da63429358554169697fa466345b8fd
GitHub-Last-Rev: 86c8a2dd89
GitHub-Pull-Request: golang/go#74561
Reviewed-on: https://go-review.googlesource.com/c/go/+/687215
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
parent
ca0e03560d
commit
61dc7fe30d
1 changed files with 2 additions and 0 deletions
|
|
@ -28,6 +28,8 @@ or index-value pairs.
|
||||||
Yield returns true if the iterator should continue with the next
|
Yield returns true if the iterator should continue with the next
|
||||||
element in the sequence, false if it should stop.
|
element in the sequence, false if it should stop.
|
||||||
|
|
||||||
|
Yield panics if called after it returns false.
|
||||||
|
|
||||||
For instance, [maps.Keys] returns an iterator that produces the sequence
|
For instance, [maps.Keys] returns an iterator that produces the sequence
|
||||||
of keys of the map m, implemented as follows:
|
of keys of the map m, implemented as follows:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue