Instance Method インスタンスメソッド

next()

Advances to the next element and returns it, or nil if no next element exists. 次の要素へ進んでそれを返します、または次の要素が存在しないならばnilを返します。

Declaration 宣言

mutating func next() -> LazyDropWhileSequence<Base>.Iterator.Element?

Return Value 戻り値

The next element in the underlying sequence, if a next element exists; otherwise, nil. 次の要素が存在するならば、基礎をなすシーケンス中の次の要素;そうでなければ、nil

Discussion 解説

Repeatedly calling this method returns, in order, all the elements of the underlying sequence. As soon as the sequence has run out of elements, all subsequent calls return nil. 繰り返しこのメソッドを呼び出すことは、基礎をなすシーケンスのすべての要素を、順番に返します。シーケンスが要素を使い果たすやいなや、全てのその後の呼び出しはnilを返します。

You must not call this method if any other copy of this iterator has been advanced with a call to its next() method. あなたは、このイテレータの何か他のコピーがそれのnext()メソッドを呼び出すことで前に進められるならば、このメソッドを呼び出す必要はありません。

The following example shows how an iterator can be used explicitly to emulate a for-in loop. First, retrieve a sequence’s iterator, and then call the iterator’s next() method until it returns nil. 次の例は、イテレータが明示的に使われてfor-inループの機能を真似る方法を示します。まず、あるシーケンスのもつイテレータを見つけて取ってきてください、そしてそのイテレータの持つnext()メソッドを、それがnilを返すまで呼び出してください。


let numbers = [2, 3, 5, 7]
var numbersIterator = numbers.makeIterator()


while let num = numbersIterator.next() {
    print(num)
}
// Prints "2"
// Prints "3"
// Prints "5"
// Prints "7"

Relationships 関係

From Protocol 由来プロトコル