Created
September 8, 2014 00:04
-
-
Save malclocke/7072185045b469f025c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def value_of_first_matching_key_in_hash(hash, array_of_keys) | |
end | |
describe do | |
it 'searches a hash for an array of keys and returns the value of the first found' do | |
keys = [:a, :b, :c] | |
hash = {:c => 3, :b => 2, :a => 1} | |
expect(value_of_first_matching_key_in_hash(hash, keys)).to eql 1 | |
hash = {:z => 1, :b => 2, :c => 3} | |
expect(value_of_first_matching_key_in_hash(hash, keys)).to eql 2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment