Skip to content

Instantly share code, notes, and snippets.

@eladmeidar
Created March 2, 2015 16:13
Show Gist options
  • Save eladmeidar/5c36f7e9061aa0f723ea to your computer and use it in GitHub Desktop.
Save eladmeidar/5c36f7e9061aa0f723ea to your computer and use it in GitHub Desktop.
Check if all array keys are in hash keys
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