Created
August 31, 2018 03:27
-
-
Save redconfetti/3daa031f7ad4f7bd6311482d659a1aeb to your computer and use it in GitHub Desktop.
Enumerable.find - Hash and Key and Value Match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It does work | |
my_hash = {a: 1, b: 2, c: 3, d: 4, e: 5} | |
my_hash.find {|k,v| puts "k:#{k},v:#{v}"; v == 3} | |
# Output: | |
# k:a,v:1 | |
# k:b,v:2 | |
# k:c,v:3 | |
# => [:c, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment