4件ヒット
[1-4件を表示]
(0.035秒)
別のキーワード
キーワード
- [] (1)
-
fetch
_ values (2) -
values
_ at (1)
検索結果
先頭4件
-
Hash
# values _ at(*keys) -> [object] (69013.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... -
Hash
# [](key) -> object | nil (31.0) -
key に関連づけられた値を返します。
...る必要が
ある場合は Hash#fetch または Hash#key? を使ってください。
@param key 探索するキーを指定します。
//emlist[例][ruby]{
h = {:ab => "some" , :cd => "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
# fetch _ values(key , . . . ) -> [object] (31.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...=> "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}
@see Hash#values_at, Hash#fetch... -
Hash
# fetch _ values(key , . . . ) { |key| . . . } -> [object] (31.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...=> "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}
@see Hash#values_at, Hash#fetch...