# Class goog.iter.Iterator.`<VALUE>`

code »

Class/interface for iterators. An iterator needs to implement a `next` method and it needs to throw a `goog.iter.StopIteration` when the iteration passes beyond the end. Iterators have no `hasNext` method. It is recommended to always use the helper functions to iterate over the iterator or in case you are only targeting JavaScript 1.7 for in loops.

## Constructor

goog.iter.Iterator ( )
Show:PublicProtectedPrivate

## Instance Methods

code » __iterator__ ( opt_keys ) ⇒ `!goog.iter.Iterator.<VALUE>`

Returns the `Iterator` object itself. This is used to implement the iterator protocol in JavaScript 1.7

Parameters

opt_keys: `boolean=`
  Whether to return the keys or values. Default is to only return the values. This is being used by the for-in loop (true) and the for-each-in loop (false). Even though the param gives a hint about what the iterator will return there is no guarantee that it will return the keys when true is passed.

Returns

The object itself.

code » next ( ) ⇒ `VALUE`

Returns the next value of the iteration. This will throw the object goog.iter#StopIteration when the iteration passes the end.

Returns

Any object or value.