basically the title, I would need to check the params and do different things depending on whether there is a parameter with a value, is that value nil or not, or the parameter is not there at all.
Is this possible?
Thank you
basically the title, I would need to check the params and do different things depending on whether there is a parameter with a value, is that value nil or not, or the parameter is not there at all.
Is this possible?
Thank you
case Map.fetch(params, key) do
{:ok, nil} -> # it's here and it's nil
{:ok, value} -> # it's here and it's not nil
:error -> # it isn't present
end
case params do
%{"foo" => nil} -> # it is nil
%{"foo" => val} -> # it is there and has a value
%{} -> # it is not there
end