Server IP : 66.29.132.122 / Your IP : 18.227.111.53 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/ruby18/share/ri/1.8/system/Hash/ |
Upload File : |
--- !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