モジュール
-
Net
:: HTTPHeader (33)
キーワード
- fetch (73)
-
fetch
_ values (18) - key (7)
- receiver (7)
検索結果
先頭5件
-
KeyError
# key -> object (21023.0) -
KeyError の原因となったメソッド呼び出しのキーを返します。
...
KeyError の原因となったメソッド呼び出しのキーを返します。
@raise ArgumentError キーが設定されていない時に発生します。
例:
h = Hash.new
begin
h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found: \"gumbygumby... -
KeyError
# receiver -> object (21023.0) -
KeyError の原因となったメソッド呼び出しのレシーバを返します。
...
KeyError の原因となったメソッド呼び出しのレシーバを返します。
@raise ArgumentError レシーバが設定されていない時に発生します。
例:
h = Hash.new
begin
h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found:... -
Hash
# fetch(key) -> object (19.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...y 探索するキーを指定します。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。
//emlist[例][ruby]{
h = {one:......のか判別できない。
p h.fetch(:one) #=> nil
p h.fetch(:two) # エラー key not found (KeyError)
p h.fetch(:two,"error") #=> "error"
p h.fetch(:two){|key|"#{key} not exist"} #=> "two not exist"
p h.fetch(:two, "error"){|key|......o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]......wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]... -
Hash
# fetch(key) {|key| . . . } -> object (19.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...y 探索するキーを指定します。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。
//emlist[例][ruby]{
h = {one:......のか判別できない。
p h.fetch(:one) #=> nil
p h.fetch(:two) # エラー key not found (KeyError)
p h.fetch(:two,"error") #=> "error"
p h.fetch(:two){|key|"#{key} not exist"} #=> "two not exist"
p h.fetch(:two, "error"){|key|......o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]......wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]... -
Hash
# fetch(key , default) -> object (19.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...y 探索するキーを指定します。
@param default 該当するキーが登録されていない時の返り値を指定します。
@raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。
//emlist[例][ruby]{
h = {one:......のか判別できない。
p h.fetch(:one) #=> nil
p h.fetch(:two) # エラー key not found (KeyError)
p h.fetch(:two,"error") #=> "error"
p h.fetch(:two){|key|"#{key} not exist"} #=> "two not exist"
p h.fetch(:two, "error"){|key|......o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]......wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。
h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}
@see Hash#[]... -
Hash
# fetch _ values(key , . . . ) -> [object] (19.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...クが与えられていない時は
KeyError が発生します。
self にデフォルト値が設定されていても無視されます(挙動に変化がありません)。
@param key 探索するキーを任意個指定します。
@raise KeyError ブロックが与えられてない時......=> "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] (19.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...クが与えられていない時は
KeyError が発生します。
self にデフォルト値が設定されていても無視されます(挙動に変化がありません)。
@param key 探索するキーを任意個指定します。
@raise KeyError ブロックが与えられてない時......=> "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... -
Net
:: HTTPHeader # fetch(key) -> String (7.0) -
key ヘッダフィールドを返します。
.../}
//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'
begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}
//emlist[例 key , default を指定][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.c... -
Net
:: HTTPHeader # fetch(key) {|hash| . . . . } -> String (7.0) -
key ヘッダフィールドを返します。
.../}
//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'
begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}
//emlist[例 key , default を指定][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.c... -
Net
:: HTTPHeader # fetch(key , default) -> String (7.0) -
key ヘッダフィールドを返します。
.../}
//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'
begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end
//}
//emlist[例 key , default を指定][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.c... -
Thread
# fetch(name , default = nil) {|name| . . . } -> object (7.0) -
name に関連づけられたスレッドに固有のデータを返します。 name に対応するスレッド固有データがない時には、引数 default が 与えられていればその値を、ブロックが与えられていれば そのブロックを評価した値を返します。
...Symbol で指定します。
@param default name に対応するスレッド固有データがない時の返り値を指定します。
@raise KeyError 引数defaultもブロックも与えられてない時、
name に対応するスレッド固有データがないと発生しま...