Closed warmwaffles closed 9 months ago
Hey @warmwaffles thanks for this.
While I understand the criteria, the idea of returning nil
was some sort of "unsupported and/or not recognized format", in case other formats are provided, while false
indicates purely that the binary it is not that image format.
However, if no objections, I'll accept it in a couple of days ;)
Heh, the docs don't specify that nil
means it is unsupported though. Just says "false otherwise".
Not a huge deal, just didn't realize that it was intentional. My use case is just checking if the image file type is supported in our application. Which we would coerce the nil
to false
using ==
@spec supported(String.t()) :: boolean()
def supported?(path) do
case File.read(path) do
{:ok, content} -> ExImageInfo.seems?(content) == true
_ -> false
end
end
Sorry, in that case I missed that in the docs. Do you mind we keep the original behavior? In that case, maybe you can update the docs in this PR ;)
Yea I can open another PR with the docs rectified. There are other places where I can see nil
is being used.
Predicate methods should always return a boolean. Mixing
true | false | nil
is a bit inconsistent.