How to use return statement with if condition in elixir?

You can’t return early in elixir, but there’s another constuct for such operations:

cond do
  a > b -> {:ok, "a"}
  a < b -> {:ok, "b"}
  a == b -> {:ok, "equal"}
end