In Elixir's intro to GenServer, the client API starts the server with an :ok
argument
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
And the server's init
function requires its argument to be :ok
def init(:ok) do
{:ok, HashDict.new}
end
What's the point of passing and verifying :ok
? Would it be any different if we were to omit this and instead write something like
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, nil, opts)
end
def init(_) do
{:ok, HashDict.new}
end
?