Project

General

Profile

Actions

Feature #9174

open

value receiving block for Hash#has_key?

Added by rits (First Last) over 10 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:58668]

Description

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

No data to display

Actions

Also available in: Atom PDF

Like0