1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-01 04:20:39 +02:00

Merge pull request #2036 from fighterleslie/pr-hash

[ruby/en] Replace Hash#has_key? with Hash#key?
This commit is contained in:
ven
2015-11-23 08:20:52 +01:00

View File

@@ -230,8 +230,8 @@ 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
new_hash.key?(:defcon) #=> true
new_hash.value?(3) #=> true
# Tip: Both Arrays and Hashes are Enumerable
# They share a lot of useful methods such as each, map, count, and more