I have created a module that looks as follow:
defmodule Sum do
    def sum(x,y) do
        x + y
    end
    def sum(x) do
        x
    end
end
and it works as I expected with pattern matching of course:
iex(2)> Sum.sum(3)
3
iex(3)> Sum.sum(3,5)
8
When I define an anonymous function like:
iex(1)> sum = fn
...(1)>  x, y -> x + y
...(1)>  x -> x
...(1)> end
** (CompileError) iex:1: cannot mix clauses with different arities in function definition
then the compiler complain. Why I can not mix with different arities, the example above with module it works like a charm.
 
     
     
    