我已经在主模块中定义了以下功能。从函数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