The Iterator-ID paragraph indicates that this Identification Division introduces an iterator definition and specifies the name that identifies the iterator. Iterator-id can be specified wherever Method-ID can be specified, and can be used to define either static or instance iterators.
General Format
Syntax Rules:
- The procedure division header of an Iterator must include a Yielding phrase. The type of the item specified in the Yielding phrase determines the type of the iterators.
- Attribute-clause is defined in the topic on the
Custom-Attribute Clause.
General Rules
- For an iterators of type T, the system will automatically generate a nested class which implements both IEnumerable[T] and IEnumerator[T].
- The system also generates a method with the name specified in the Iterator-ID paragraph. This method returns an item of the nested type defined in GR 1.
- Code outside the context of the iterators may invoke this method to return the iteration object, and iterate through it using the PERFORM THROUGH collection class syntax (see PERFORM statement format 5).
- The order in which iteration proceeds is determined by the successive RETURNING values when each EXIT ITERATOR statement is executed.