#How do I allow single line and multiline functions with the same name to exist next to eachother?

5 messages · Page 1 of 1 (latest)

lone ingot
#

I want to allow single line and multiline functions with the same name next to eachother. For example, I want this:

  defp handle_join(_socket, nil), do: {:error, :session_not_found}
  defp handle_join(_socket, %{finished: false}), do: {:error, :session_not_finished}
  defp handle_join(socket, %{finished: true} = session) do
    {:ok, assign(socket, %{session: session})}
  end

instead of this:

  defp handle_join(_socket, nil), do: {:error, :session_not_found}
  defp handle_join(_socket, %{finished: false}), do: {:error, :session_not_finished}

  defp handle_join(socket, %{finished: true} = session) do
    {:ok, assign(socket, %{session: session})}
  end
#

How do I allow single line and multiline functions with the same name to exist next to eachother?

timid turtle
#

Just do not use formatter

lone ingot
#

But I like the formatter :(

sour scaffold
#

You can also make one function instead and use a case inside it (but you can't mix inline and multiline there either)