I’m just figuring out control flows, its all very strange and confusing since I’ve never used a functional language before, could someone correct this for me:
-export([main/1, test/2]).
main([]) ->
if
test("blue yellow green", "yellow") == true ->
{io:fwrite("found")};
true ->
{io:fwrite("not found")}
end.
test(Source, Find) ->
Pos = string:str(Source, Find),
if
Pos > 1 ->
{true};
true ->
{false}
end.
The corrected version:
When you return just one element, you shouldn’t use
{and}.