diff --git a/src/iter/iter.go b/src/iter/iter.go index 3eaeb9e1fd6f1f..23fd071e32877c 100644 --- a/src/iter/iter.go +++ b/src/iter/iter.go @@ -26,7 +26,7 @@ Seq2 represents a sequence of paired values, conventionally key-value or index-value pairs. 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 must stop. For instance, [maps.Keys] returns an iterator that produces the sequence of keys of the map m, implemented as follows: @@ -51,6 +51,9 @@ Iterator functions are most often called by a [range loop], as in: } } +If a [range loop] terminates, e.g. by a break statement, a subsequent call +to yield inside the iterator causes a runtime panic. + # Naming Conventions Iterator functions and methods are named for the sequence being walked: