SafeIterator places a simple stream on top of an iterator,
returning Option-wrapped instances from the underlying iterator.
When the stream is exhausted, the Iterator stream returns
None. Differences from a plain Iterator include:
- An SafeIterator will not throw an exception if you try to read
past the end of it. Instead, it will just keep returning None.
Example of use with a string:
import grizzled.parsing.SafeIterator
val s = ...
val istream = new SafeIterator[Char](s.elements)
SafeIterator
places a simple stream on top of an iterator, returningOption
-wrapped instances from the underlying iterator. When the stream is exhausted, theIterator
stream returnsNone
. Differences from a plainIterator
include:- An
SafeIterator
will not throw an exception if you try to read past the end of it. Instead, it will just keep returningNone
.Example of use with a string: