4
0
Fork 0

Refactor options' checkers so they are explicitly compared to nil when given in a list

pull/11/head
Piotr Żelazko 6 years ago
parent fea7f19232
commit 86927171d1
No known key found for this signature in database
GPG Key ID: 27E11A19853A7913
  1. 11
      lib/exw3.ex

@ -550,16 +550,9 @@ defmodule ExW3 do
# Options' checkers # Options' checkers
defp check_option(nil, error_atom), do: {:error, error_atom} defp check_option(nil, error_atom), do: {:error, error_atom}
defp check_option([], error_atom), do: {:error, error_atom} defp check_option([], error_atom), do: {:error, error_atom}
defp check_option([head | tail], atom) do defp check_option([head | tail], atom) when head != nil, do: {:ok, head}
if head do defp check_option([_head | tail], atom), do: check_option(tail, atom)
{:ok, head}
else
check_option(tail, atom)
end
end
defp check_option(value, _atom), do: {:ok, value} defp check_option(value, _atom), do: {:ok, value}
# Casts # Casts

Loading…
Cancel
Save