[erlang-questions] Overloaded function specifications as types
Mon Jan 23 12:32:05 CET 2017
> > -spec bar(fun((integer()) -> integer()) | fun((atom()) -> atom())) -> ok.
> > %% Allows fun erlang:atom_to_list/1, which doesn't work on integers at
> I'm seriously confused as I do not see anything related to lists here...
> Can you elaborate?
I'm sorry, editing mistake! atom_to_list is of course not a good example.
(I started off with different code samples and edited them a couple of
The correct example would be a function that only takes atoms and returns
good_example(ok) -> ok;
good_example(Other) when is_atom(Other) -> error.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions