るりまサーチ

最速Rubyリファレンスマニュアル検索!
30件ヒット [1-30件を表示] (0.027秒)
トップページ > クエリ:on[x] > クエリ:StopIteration[x]

別のキーワード

  1. optionparser on
  2. optparse on
  3. tracer on
  4. thread abort_on_exception
  5. thread abort_on_exception=

ライブラリ

クラス

キーワード

検索結果

StopIteration (44000.0)

イテレーションを止めるときに発生する例外です。

イテレーションを止めるときに発生する例外です。

StopIteration#result -> object (24006.0)

この例外オブジェクトを発生させる原因となったメソッド等の返り値を返します。

...ect = Object.new
def object.each
yield :yield1
yield :yield2
:each_returned
end

enumerator = object.to_enum

p enumerator.next #=> :yield1
p enumerator.next #=> :yield2

begin
enumerator.next
rescue StopIteration => error
p error.result #=> :each_returned
end...

Fiber#raise(exception, message = nil, backtrace = nil) -> object (106.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...をメッセージとした RuntimeError
が発生します。

その他のケースでは、最初の引数は Exception か Exception
のインスタンスを返す exception メソッドを持ったオブジェクトである
必要があります。
この場合、2つ目の引数に例外の...
...例外発生時のスタックトレースを指定できます。

@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist...
...{ Fiber.yield }
f.resume
f.raise "Error!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end
:exit
end

p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...