95件ヒット
[1-95件を表示]
(0.118秒)
ライブラリ
- ビルトイン (95)
クラス
- Hash (77)
- Thread (7)
- ThreadGroup (11)
検索結果
先頭5件
-
Hash
# default -> object | nil (26211.0) -
ハッシュのデフォルト値を返します。
...なることに注意してください。この場合、ハッシュのデフォルト値に
ついて調べるには 2 番目の形式か Hash#default_proc を使ってください。
2 番目の形式はハッシュがデフォルト値としてブロックを持つ場合に、
self と引数 ke......sh.new("default")
p h.default #=> "default"
p h.default(:some) #=> "default"
p h #=>{}
h = Hash.new{|hash, key| hash[key] ="default" }
p h.default #=> nil
p h.default(:some) #=> "default"
p h #=> {:some=>"default"}
h = Hash.new
p h.default #=> nil
p h.default(:s......ome) #=> nil
p h #=> {}
//}
@see Hash#default=, Hash#default_proc... -
Hash
# default(key) -> object | nil (26211.0) -
ハッシュのデフォルト値を返します。
...なることに注意してください。この場合、ハッシュのデフォルト値に
ついて調べるには 2 番目の形式か Hash#default_proc を使ってください。
2 番目の形式はハッシュがデフォルト値としてブロックを持つ場合に、
self と引数 ke......sh.new("default")
p h.default #=> "default"
p h.default(:some) #=> "default"
p h #=>{}
h = Hash.new{|hash, key| hash[key] ="default" }
p h.default #=> nil
p h.default(:some) #=> "default"
p h #=> {:some=>"default"}
h = Hash.new
p h.default #=> nil
p h.default(:s......ome) #=> nil
p h #=> {}
//}
@see Hash#default=, Hash#default_proc... -
Hash
# default _ proc -> Proc | nil (14156.0) -
ハッシュのデフォルト値を返す Proc オブジェクトを返します。 ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。
...by]{
h = Hash.new {|hash, key| "The #{key} not exist in #{hash.inspect}"}
p h.default #=> nil
p block = h.default_proc #=> #<Proc:0x0x401a9ff4>
p block.call({},:foo) #=> "The foo not exist in {}"
h = Hash.new("default")
p h.default #=> "default"
p h.default_proc......#=> nil
//}
@see Hash#default... -
Thread
# fetch(name , default = nil) {|name| . . . } -> object (8136.0) -
name に関連づけられたスレッドに固有のデータを返します。 name に対応するスレッド固有データがない時には、引数 default が 与えられていればその値を、ブロックが与えられていれば そのブロックを評価した値を返します。
...い時には、引数 default が
与えられていればその値を、ブロックが与えられていれば
そのブロックを評価した値を返します。
@param name スレッド固有データのキーを文字列か Symbol で指定します。
@param default name に対応するス......の返り値を指定します。
@raise KeyError 引数defaultもブロックも与えられてない時、
name に対応するスレッド固有データがないと発生します。
//emlist[例][ruby]{
th = Thread.new { Thread.current[:name] = 'A' }
th.join
th.fetch(:name) #... -
Hash
# [](key) -> object | nil (8043.0) -
key に関連づけられた値を返します。
..."all"}
p h[:ab] #=> "some"
p h[:ef] #=> nil
h1 = Hash.new("default value")
p h1[:non] #=> "default value"
h2 = Hash.new {|*arg| arg}
p h2[:non] #=> [{}, :non]
//}
@see Hash.new, Hash#fetch,Hash#values_at,Hash#key?, Hash#default, Hash#default_proc... -
Hash
# shift -> [object , object] | nil (8037.0) -
ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。
...elfは要素を取り除かれた残りのハッシュに変更されます。
ハッシュが空の場合、デフォルト値(Hash#defaultまたはHash#default_procのブロックの値か、どちらもnilならばnil)
を返します(このとき、[key,value] という形式の値を返す......#=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil
h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> "default value"
h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=> [{}, nil]
//}
@see Ar... -
ThreadGroup
# add(thread) -> self (8031.0) -
スレッド thread が属するグループを自身に変更します。
...p::Default.list}"
# => Initial group is [#<Thread:0x4a49168 run>]
tg = ThreadGroup.new
t1 = Thread.new { sleep }
t2 = Thread.new { sleep }
puts "t1 is #{t1}" # => t1 is #<Thread:0x50bef60>
puts "t2 is #{t2}" # => t2 is #<Thread:0x50beed0>
tg.add(t1)
puts "Initial group now #{ThreadGroup::Default.li... -
Hash
# clear -> self (8025.0) -
ハッシュの中身を空にします。
...ハッシュの中身を空にします。
空にした後のselfを返します。
デフォルト値の設定はクリアされません。
//emlist[例][ruby]{
h = Hash.new("default value")
h[:some] = "some"
p h #=> {:some=>"some"}
h.clear
p h #=> {}
p h.default #=> "default value"
//}... -
Hash
# values _ at(*keys) -> [object] (8019.0) -
引数で指定されたキーに対応する値の配列を返します。
...引数が指定されなかった場合は、空の配列を返します。
//emlist[例][ruby]{
h = {1=>"a", 2=>"b", 3=>"c"}
p h.values_at(1,3,4) #=> ["a", "c", nil]
# [h[1], h[3] ,h[4]] と同じ
//}
@see Hash#[] , Hash.new, Hash#default, Hash#default_proc, Array#values_at...