Both enumerations and iterations provide the ability to traverse the elements of a collection object.
I. Enumeration
Refers to calling an enumeration function, enumerating the elements of the collection at a single point, usually by specifying a trigger function as an argument. Enumeration functions are prefixed with an enum. For example, the Winex.enum enumeration function can enumerate all the desktop windows.
Io.open ();
Import Winex;
Winex.enum (
function (hwnd,depth) {
.. Io.print (Depth,hwnd,win.gettext (HWND);
}
}
All enumerated functions must conform to the Convention at design time: return False to stop the enumeration.
Two. Iteration
Iterative functions are typically used in for...in statements to create an iterator that traverses a collection member. The iteration function is prefixed with each. such as Com.each function, Winex.each function.
Io.open ();
Import Winex;
For Hwnd,title,theadid in Winex.each () {
io.print (hwnd,title,theadid);
}
Three. The difference between iterations and enumerations
An iteration is a breadth traversal, usually traversing a collection object at the same depth, iterating through one member of the collection at a time in a loop.
Enumerations can iterate through the collection in a recursive depth and enumerate the elements of the collection at once.