# Enumerator Object [AHK_L 49+]

Allows items in a collection to be enumerated.

## Next

Retrieves the next item or items in an enumeration.

    Enum.Next(OutputVar1 [, OutputVar2, ...])

OutputVar1, OutputVar2 | Receives an implementation-specific value.
... | Additional parameters, if supported.
Returns | A non-zero integer if successful, zero if there were no items remaining, or an empty string if parameters were incorrect.

### Object

Enumerators returned by ObjNewEnum() are called once for each key-value pair, and allow up to two parameters:

OutputVar1 | Receives the key in a key-value pair.
OutputVar2 | Receives the value associated with OutputVar1.

Key-value pairs are returned in an implementation-defined order. That is, they are typically not returned in the same order that they were assigned. Existing key-value pairs may be modified during enumeration, but inserting or removing keys may cause some items to be enumerated multiple times or not at all.

### Related

For-loop, Object.NewEnum()

### Example

    ; Create some sample data.
    obj := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00)

    ; Enumerate!
    enum := obj._NewEnum()
    While enum[k, v]
        t .= k "=" v "`n"
    MsgBox % t

    ; AHK_L 59+
    For k, v in obj
        s .= k "=" v "`n"
    MsgBox % s