Issue #9174 has been reported by rits (First Last).

----------------------------------------
Feature #9174: value receiving block for Hash#has_key?
https://bugs.ruby-lang.org/issues/9174

Author: rits (First Last)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Seems useful to be able to check for presence (as opposed to falsyness) and receive the value 

class Hash
  def has_key?(key, &block)
    val = fetch(key){return false}
    block.(val) if block
    true
  end
end


if h.has_key? :key do |val|
  #
end; else
  #
end



-- 
http://bugs.ruby-lang.org/