GeneratorOfOne

struct GeneratorOfOne<T>

A generator that produces one or fewer instances of T.

Inheritance GeneratorType, SequenceType, _SequenceType, _Sequence_Type View Protocol Hierarchy →
Associated Types
Generator = GeneratorOfOne<T>

Type alias inferred.

Element = Generator.Element

Type alias inferred.

Import import Swift

Initializers

init(_:)

Construct an instance that generates element!, or an empty sequence if element == nil.

Declaration

init(_ element: T?)

Instance Methods

func generate()

GeneratorOfOne is also a SequenceType, so it generates a copy of itself

Declaration

func generate() -> GeneratorOfOne<T>
mutating func next()

Advance to the next element and return it, or nil if no next element exists.

Requires: next() has not been applied to a copy of self since the copy was made, and no preceding call to self.next() has returned nil.

Declaration

mutating func next() -> T?