使用 IEx.pry 引发编译错误

Mar*_*ior 3 elixir

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

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

~ 猫 foo.ex

defmodule Math do

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

end

IO.puts(Math.add(1, 2))
Run Code Online (Sandbox Code Playgroud)

~长生不老药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
Run Code Online (Sandbox Code Playgroud)

我没有看到该模块的任何参考: Integer, Kernel, Kernel.Typespec, Record in the docs。所以我不知道如何继续。

我正在使用该Elixir 0.11.1-dev版本。

提前致谢

Jos*_*lim 5

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

require IEx
IEx.pry
Run Code Online (Sandbox Code Playgroud)

你应该很高兴去。