shift73k/lib/bones73k/util/list.ex

5 lines
204 B
Elixir
Raw Normal View History

2021-02-25 16:39:03 -05:00
defmodule Bones73k.Util.List do
def prepend_if(list, condition, item), do: (!!condition && [item | list]) || list
def append_if(list, condition, item), do: (!!condition && list ++ [item]) || list
end