gpt4 book ai didi

elixir - 使用 IEx.pry 引发编译错误

转载 作者:行者123 更新时间:2023-12-01 11:41:43 25 4
gpt4 key购买 nike

抱歉,如果这是一个简单的问题,但我对 elixir 很陌生,而且我没有 erlang 背景。

我正在尝试运行以下代码,但出现错误。

~ 猫 foo.ex

defmodule Math do

def add(a, b) do
a + b
IEx.pry
end

end

IO.puts(Math.add(1, 2))

~ Elixir foo.ex

** (CompileError) foo.ex:5: tried to invoke macro IEx.pry/0 but module was not required. Required: Integer, Kernel, Kernel.Typespec, Record
src/elixir_dispatch.erl:209: :elixir_dispatch.expand_macro_fun/7
src/elixir_dispatch.erl:197: :elixir_dispatch.expand_require/6
src/elixir_dispatch.erl:116: :elixir_dispatch.dispatch_require/6
lists.erl:1329: :lists.mapfoldl/3
lists.erl:1330: :lists.mapfoldl/3
src/elixir_translator.erl:59: :elixir_translator.translate_each/2
lists.erl:1329: :lists.mapfoldl/3

我没有看到该模块的任何引用:Integer、Kernel、Kernel.Typespec、Record in the docs .所以我不知道如何进行。

我使用的是 Elixir 0.11.1-dev 版本。

提前致谢

最佳答案

您需要在使用 IEx 模块之前明确要求它:

require IEx
IEx.pry

你应该可以开始了。

关于elixir - 使用 IEx.pry 引发编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19814930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com