260件ヒット
[1-100件を表示]
(0.117秒)
ライブラリ
- ビルトイン (76)
- dbm (11)
- gdbm (11)
-
net
/ http (33) - pstore (11)
-
rubygems
/ remote _ fetcher (11) -
rubygems
/ spec _ fetcher (22) - tsort (85)
クラス
- DBM (11)
- GDBM (11)
-
Gem
:: RemoteFetcher (11) -
Gem
:: SpecFetcher (22) - Hash (62)
- KeyError (14)
- PStore (11)
モジュール
-
Net
:: HTTPHeader (33) - TSort (85)
キーワード
- [] (11)
-
each
_ strongly _ connected _ component (21) -
each
_ strongly _ connected _ component _ from (21) -
fetch
_ path (11) -
fetch
_ values (18) - key (7)
-
latest
_ specs (11) - receiver (7)
- specs (11)
-
strongly
_ connected _ components (11) - tsort (11)
-
tsort
_ each (21)
検索結果
先頭5件
-
Hash
# fetch(key) -> object (39152.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...default が与えられていればその値を、ブロッ
クが与えられていればそのブロックを評価した値を返します。
fetchはハッシュ自身にデフォルト値が設定されていても単に無視します(挙動に変化がありません)。
@param key 探......判別できない。
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 (39152.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...default が与えられていればその値を、ブロッ
クが与えられていればそのブロックを評価した値を返します。
fetchはハッシュ自身にデフォルト値が設定されていても単に無視します(挙動に変化がありません)。
@param key 探......判別できない。
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 (39152.0) -
key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。
...default が与えられていればその値を、ブロッ
クが与えられていればそのブロックを評価した値を返します。
fetchはハッシュ自身にデフォルト値が設定されていても単に無視します(挙動に変化がありません)。
@param key 探......判別できない。
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] (27139.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] (27139.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
# [](key) -> object | nil (21073.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... -
Net
:: HTTPHeader # fetch(key) {|hash| . . . . } -> String (18229.0) -
key ヘッダフィールドを返します。
...http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("user-agent") # => "Ruby"
//}
//emlist[例 key のみ指定。key が存在しない][ruby]{
require 'net/http'
begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-lengt......:HTTP::Get.new(uri.request_uri)
req.fetch("content-length", "default") # => "default"
//}
//emlist[例 key とブロックを指定][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # =>... -
GDBM
# fetch(key , ifnone = nil) {|key| . . . } -> object (18144.0) -
データベースから対応するキーを探してその要素の値を返します。
...fetch('a') #=> 'aaa'
p db1.fetch('z', 'zzz') #=> 'zzz'
p db1.fetch('z'){|key| [:key, key] } #=> [:key, 'z']
p db1.fetch('z', 'zzz'){|key| [:key, key] } #=> 'zzz'
p db1.fetch('z') #=> IndexError 発生
@see Hash......#fetch... -
DBM
# fetch(key , ifnone = nil) -> String (18138.0) -
データベースからキーを探して対応する要素の値を返します。
...('aaa.db', 0666, DBM::NEWDB)
db1[:a] = 'aaa'
db1[:b] = 'bbbbbb'
p db1.fetch('a') #=> 'aaa'
p db1.fetch('z', 'zzz') #=> 'zzz'
p db1.fetch('z'){|key| [:key, key] } #=> [:key, 'z']
p db1.fetch('z') #=> IndexError 発生
@see Hash#fetch... -
PStore
# fetch(name , default = PStore :: Error) -> object (18132.0) -
ルートnameに対応する値を得ます。
...]
ary = db["root"] = [1,2,3,4]
ary[0] = [1,1.5]
end
db.transaction(true) do |pstore|
pstore.fetch("root") # => [[1, 1.5], 2, 3, 4]
pstore.fetch("root", 'aaa') # => [[1, 1.5], 2, 3, 4]
pstore.fetch("not_root") # => 例外発生
end
@see Hash#fetch, PStore#[]...