When should an Erlang function return ok?

Viewed 4279

I often see Erlang functions return ok, or {ok, <some value>}, or {error, <some problem>}.

Suppose my function returns an integer N. Should my function return just N, or {ok, N}?

Or suppose my function includes the call io:function("Yada yada"). Should it return ok or nothing at all?

Or suppose I'm making a record or fun. Should I return {ok, R} or (ok, F}?

Thanks,

LRP

3 Answers
Related