case Enum.filter(list, fn a → a.name == ^name end) do
a → a
_ → []
end
based on name it will give the list and if the name is not present it would give me an empty list. So I thought to use this behavior by case statement. But it’s giving me a warning
this clause cannot match because a previous clause at line 15 always matches
a in this case matches everything, because it is an assignable variable. So this case will always return 0.
Why exactly?
a is not pinned, if you want to match on a then you have to pin the variable - however… you assigned a in a function inside Enum.filter - so the variable would not be available outside of the filter function anyways.