Skip to content

Commit 61dc7fe

Browse files
narqogopherbot
authored andcommitted
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: 86c8a2d GitHub-Pull-Request: #74561 Reviewed-on: https://go-review.googlesource.com/c/go/+/687215 Auto-Submit: Sean Liao <[email protected]> Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Mark Freeman <[email protected]>
1 parent ca0e035 commit 61dc7fe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/iter/iter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ or index-value pairs.
2828
Yield returns true if the iterator should continue with the next
2929
element in the sequence, false if it should stop.
3030
31+
Yield panics if called after it returns false.
32+
3133
For instance, [maps.Keys] returns an iterator that produces the sequence
3234
of keys of the map m, implemented as follows:
3335

0 commit comments

Comments
 (0)