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
defp check_option(nil, error_atom), do: {:error, error_atom}
defp check_option([], error_atom), do: {:error, error_atom}
defp check_option([head | tail], atom) do
if head do
{:ok, head}
else
check_option(tail, atom)
end
end
defp check_option([head | tail], atom) when head != nil, do: {:ok, head}
defp check_option([_head | tail], atom), do: check_option(tail, atom)
defp check_option(value, _atom), do: {:ok, value}
# Casts

Loading…
Cancel
Save