How to check if two or more keys is are a member o of a list

I have a list of items containing a key and value eg [a: 1, b: 3, c: 6] and want to check if the list contains two or more keys.

I tried using List.keymember? But it seems to be working if you are check if one key is contained in that list

How can I check if the list contains two or more keys?

You could use Enum.all? on the second list. Like:

def has_keys?(list, keys) do
  Enum.all?(keys, fn key -> Keyword.has_key?(list, key) end)
end
1 Like

Thanks alot. It worked… I really had a headache with that. Thanks again

1 Like

No problem! Glad it worked