Hello , I have 3 fn which create and check list, but it does not work for me .
for example :
list creator :
defp string_to_array(string) when is_binary(string) do
String.split(string, [" ", ","])
end
and check fn :
defp merge_db_plug_category(query, group_acl) when group_acl in ["admin"] do
IO.puts "1"
IO.inspect group_acl
end
defp merge_db_plug_category(query, group_acl) do
IO.puts "2"
IO.inspect group_acl
end
I get ["admin"] list when I send and inspect group_acl, but always merge_db_plug_category(query, group_acl) works , why doesn’t when group_acl in ["admin"] work for me ?
Set functions aren’t expressable in a guard safe way you need to move the check into the body of the function or use recursion over the list and build a map of valid entries/roles where you then can again pattern match on.