Created
March 2, 2015 16:13
-
-
Save eladmeidar/5c36f7e9061aa0f723ea to your computer and use it in GitHub Desktop.
Check if all array keys are in hash keys
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
def do_we_have?(hash = {}, keys = []) | |
hash_keys = hash.keys.map {|key| key.to_s } | |
found_all = true | |
keys.each do |key| | |
unless hash_keys.include?(key) | |
found_all = false | |
end | |
end | |
return found_all | |
end | |
puts do_we_have?({elad: "ok", michael: "lazy"}, ["elad", "michael"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment