从模块内的公共函数调用私有函数会导致CompileError

时间:2019-02-23 14:00:56

标签: elixir

我已经在主模块中定义了以下功能。从函数movie_title调用id_title,但引发编译错误

defp id_title(title) do
    {k, v} = title
    with {:ok, primary} = Map.fetch(v, "primary"),
         {:ok, movie_title} = Map.fetch(primary, "title"),
         do: %{k=> movie_title} 
  end  

  def movie_titles(map) do
    titles = Map.get(map, "titles")
    Enum.map(titles, id_title)
  end  

错误

== Compilation error in file lib/moviematch.ex ==
** (CompileError) lib/moviematch.ex:48: undefined function id_title/0
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

0 个答案:

没有答案