Using Ruby, what is the most efficient way to check if any key in a hash matches any values within a
- by Jason
I want to compare the keys in a hash of parameters against an array of elements for a match.
For example:
params = {"key1", "key2", "key3"}
params_to_match = ["key2","key3"]
I could do this, but I'm sure there is a much more elegant way to acheive the same result
params.each_key{|key|
if params_to_match.include?(key.to_s)
return
end
}