PATH:
opt
/
alt
/
ruby18
/
share
/
ri
/
1.8
/
system
/
Hash
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: "Returns a value from the hash for the given key. If the key can't be found, there are several options: With no other arguments, it will raise an <tt>IndexError</tt> exception; if <em>default</em> is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned." - !ruby/struct:SM::Flow::VERB body: " h = { "a" => 100, "b" => 200 }\n h.fetch("a") #=> 100\n h.fetch("z", "go fish") #=> "go fish"\n h.fetch("z") { |el| "go fish, #{el}"} #=> "go fish, z"\n" - !ruby/struct:SM::Flow::P body: The following example shows that an exception is raised if the key is not found and a default value is not supplied. - !ruby/struct:SM::Flow::VERB body: " h = { "a" => 100, "b" => 200 }\n h.fetch("z")\n" - !ruby/struct:SM::Flow::P body: <em>produces:</em> - !ruby/struct:SM::Flow::VERB body: " prog.rb:2:in `fetch': key not found (IndexError)\n from prog.rb:2\n" full_name: Hash#fetch is_singleton: false name: fetch params: | hsh.fetch(key [, default] ) => obj hsh.fetch(key) {| key | block } => obj visibility: public
[-] reject-i.yaml
[edit]
[-] size-i.yaml
[edit]
[-] pretty_print_cycle-i.yaml
[edit]
[-] fetch-i.yaml
[edit]
[-] indices-i.yaml
[edit]
[-] rehash-i.yaml
[edit]
[-] empty%3f-i.yaml
[edit]
[-] to_yaml-i.yaml
[edit]
[-] values_at-i.yaml
[edit]
[-] hash-i.yaml
[edit]
[-] invert-i.yaml
[edit]
[-] pretty_print-i.yaml
[edit]
[-] yaml_initialize-i.yaml
[edit]
[-] %5b%5d%3d-i.yaml
[edit]
[-] key%3f-i.yaml
[edit]
[-] index-i.yaml
[edit]
[-] values-i.yaml
[edit]
[-] default-i.yaml
[edit]
[-] include%3f-i.yaml
[edit]
[-] each_key-i.yaml
[edit]
[-] merge-i.yaml
[edit]
[-] initialize_copy-i.yaml
[edit]
[-] each_pair-i.yaml
[edit]
[-] member%3f-i.yaml
[edit]
[-] inspect-i.yaml
[edit]
[-] delete-i.yaml
[edit]
[-] update-i.yaml
[edit]
[-] cdesc-Hash.yaml
[edit]
[-] clear-i.yaml
[edit]
[-] reject%21-i.yaml
[edit]
[-] store-i.yaml
[edit]
[-] keys-i.yaml
[edit]
[-] %3d%3d-i.yaml
[edit]
[-] to_hash-i.yaml
[edit]
[-] %5b%5d-c.yaml
[edit]
[-] %5b%5d-i.yaml
[edit]
[-] to_a-i.yaml
[edit]
[-] eql%3f-i.yaml
[edit]
[-] default%3d-i.yaml
[edit]
[-] length-i.yaml
[edit]
[+]
..
[-] merge%21-i.yaml
[edit]
[-] has_key%3f-i.yaml
[edit]
[-] each_value-i.yaml
[edit]
[-] delete_if-i.yaml
[edit]
[-] select-i.yaml
[edit]
[-] default_proc-i.yaml
[edit]
[-] each-i.yaml
[edit]
[-] indexes-i.yaml
[edit]
[-] sort-i.yaml
[edit]
[-] new-c.yaml
[edit]
[-] has_value%3f-i.yaml
[edit]
[-] shift-i.yaml
[edit]
[-] value%3f-i.yaml
[edit]
[-] to_s-i.yaml
[edit]
[-] replace-i.yaml
[edit]