- next_values -> Array[permalink][rdoc][edit]
- 
「次」のオブジェクトを配列で返します。 Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は StopIteration 例外を発生させます。 このメソッドは、 yield と yield nil を区別するために使えます。 next メソッドによる外部列挙の状態は他のイテレータメソッドによる内部列挙には影響を与えません。ただし、 IO#each_line のようにおおもとの列挙メカニズムが副作用を伴っている場合には影響があり得ます。 例: next と next_values の違いを o = Object.new def o.each yield yield 1 yield 1, 2 yield nil yield [1, 2] end e = o.to_enum p e.next_values p e.next_values p e.next_values p e.next_values p e.next_values e = o.to_enum p e.next p e.next p e.next p e.next p e.next ## yield args next_values next # yield [] nil # yield 1 [1] 1 # yield 1, 2 [1, 2] [1, 2] # yield nil [nil] nil # yield [1, 2] [[1, 2]] [1, 2]- [EXCEPTION] StopIteration:
- 列挙状態が既に最後へ到達しているとき
 [SEE_ALSO] Enumerator#next, Enumerator#peek, Enumerator#peek_values