I have a function that returns a function. I check it with EUnit test:
string_to_options_test() ->
Parser = get_parser("-", ?OPTS_FOO_BAR),
{ok, [opt_foo, opt_bar]} = Parser("foo-bar").
It is all right. When I modify the last line, I get an error:
string_to_options_test() -> % 41
Parser = get_parser("-", ?OPTS_FOO_BAR),
Parser("foo-bar") = {ok, [opt_foo, opt_bar]}. % 43, swapped LHS and RHS,
Running the test:
urlparser.erl:43: illegal pattern
urlparser.erl:41: Warning: variable 'Parser' is unused
Why I can't use Parser
function at the left hand side of the assignment?