Current section

Files

Jump to
go_over src go_over@util.erl
Raw

src/go_over@util.erl

-module(go_over@util).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([iff/3, iffnil/2, throwaway/2]).
-spec iff(boolean(), fun(() -> LZO), LZO) -> LZO.
iff(V, F, Default) ->
case V of
true ->
F();
_ ->
Default
end.
-spec iffnil(boolean(), fun(() -> nil)) -> nil.
iffnil(V, F) ->
iff(V, F, nil).
-spec throwaway(boolean(), fun(() -> {ok, any()} | {error, any()})) -> nil.
throwaway(V, F) ->
case V of
true ->
_ = F(),
nil;
_ ->
nil
end.