11件ヒット
[1-11件を表示]
(0.102秒)
クラス
- Refinement (3)
- Thread (8)
キーワード
-
import
_ methods (3) -
report
_ on _ exception (8)
検索結果
-
Refinement
# import _ methods(*modules) -> self (6203.0) -
モジュールからメソッドをインポートします。
...モジュールからメソッドをインポートします。
Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。
メソッドをコピーするため、Rubyコードで......さい。
//emlist[][ruby]{
module StrUtils
def indent(level)
' ' * level + self
end
end
module M
refine String do
import_methods StrUtils
end
end
using M
p "foo".indent(3) # => " foo"
module M
refine String do
import_methods Enumerable
# Can't import method which is......not defined with Ruby code: Enumerable#drop
end
end
//}... -
Thread
# report _ on _ exception -> bool (6203.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...の Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception......> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thread:0x000......07fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception...