At work I ran into a bit of code that looked inelegant and the compiler complained that we had unused variables. I was wondering what the idiomatic way of handling this case is.
defp parse_create_case_response({create_status, http_status, body}) do
case {create_status, http_status} do
{:ok, 201} ->
%{"errors" => errors, "id" => id, "success" => success} = Poison.decode! body
_other ->
{:error, %{message: "Internal error", error_code: :internal_server_error}}
end
end
The compiler complained that errors, id, and error were all unused. I understand why they are unused, but I'm wondering how I should handle this. Should I put a _ in front of each variable to tell the compiler that they are unused? Or do something else entirely?
There are other problems with the code that will be addressed in code review, I'm just wondering how I should help my colleague get past the linter.