1
在工作中,我遇到了一些看起来不够优雅的代码,编译器抱怨我们有未使用的变量。我想知道处理这个案件的惯用方式是什么。elixir中的模式匹配返回值地图
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
编译器抱怨说errors
,id
和error
都不用的。我明白他们为什么没有被使用,但我想知道我应该如何处理这个问题。我应该在每个变量的前面放一个_
来告诉编译器它们没有被使用吗?或者完全做其他事情?
代码审查中还会解决其他的代码问题,我只是想知道我应该如何帮助我的同事克服这个问题。