1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-12 01:34:19 +02:00

add has_key? and has_value? methods on hashes

This commit is contained in:
Rahil Momin
2015-03-19 15:38:16 +05:30
parent 1b1d10e2d9
commit 37c00223d0

View File

@@ -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