Skip to content

Instantly share code, notes, and snippets.

@nyaray
Created April 2, 2019 20:33
Show Gist options
  • Save nyaray/acfb3c8d2ad2d7ce8708cc25a75917a2 to your computer and use it in GitHub Desktop.
Save nyaray/acfb3c8d2ad2d7ce8708cc25a75917a2 to your computer and use it in GitHub Desktop.
Observations

"Functions as named case-expressions"

  defp derive_chunk_fallback(chunk_tag, chunk_type) do
    case {chunk_tag, chunk_type} do
      {"", :start} ->
        :missing

      {"", :append} ->
        :no_chunk

      _ ->
        chunk_tag |> String.trim()
    end
  end

  defp derive_chunk_fallback("", :start), do: :missing
  defp derive_chunk_fallback("", :append), do: :no_chunk
  defp derive_chunk_fallback(chunk, _), do: chunk |> String.trim()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment