delete

hsh.delete(key) â value
hsh.delete(key) {| key | block } â value
Instance Public methods

Deletes the key-value pair and returns the value from hsh whose key is equal to key. If the key is not found, returns the default value. If the optional code block is given and the key is not found, pass in the key and return the result of block.

h = { "a" => 100, "b" => 200 }
h.delete("a")                              #=> 100
h.delete("z")                              #=> nil
h.delete("z") { |el| "#{el} not found" }   #=> "z not found"
doc_ruby_on_rails
2015-04-11 22:22:25
Comments
Leave a Comment

Please login to continue.