instance method Enumerator#feed

feed(obj) -> nil[permalink][rdoc][edit]

Enumerator 内部の yield が返す値を設定します。

これで値を設定しなかった場合は yield は nil を返します。

この値は内部で yield された時点でクリアされます。



# (1), (2), ... (10) の順に実行される
o = Object.new
def o.each
  x = yield         # (2) blocks
  p x               # (5) => "foo"
  x = yield         # (6) blocks
  p x               # (8) => nil
  x = yield         # (9) blocks
  p x               # not reached w/o another e.next
end

e = o.to_enum
e.next              # (1)
e.feed "foo"        # (3)
e.next              # (4)
e.next              # (7)
                    # (10)
[PARAM] obj:
Enumerator 内部の yield が返す値
[EXCEPTION] TypeError:
すでに値をこのメソッドでセットしている場合に発生します