mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-26 23:23:55 +00:00
add has_key? and has_value? methods on hashes
This commit is contained in:
parent
1b1d10e2d9
commit
37c00223d0
@ -191,6 +191,10 @@ new_hash = { defcon: 3, action: true }
|
||||
|
||||
new_hash.keys #=> [:defcon, :action]
|
||||
|
||||
# Check existence of keys and values in hash
|
||||
new_hash.has_key?(:defcon) #=> true
|
||||
new_hash.has_value?(3) #=> true
|
||||
|
||||
# Tip: Both Arrays and Hashes are Enumerable
|
||||
# They share a lot of useful methods such as each, map, count, and more
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user