Debugging with IEx.pry/0
is quite simple.
require IEx
in your moduleIEx.pry
after the lineNow start your project (e.g. iex -S mix
).
When the line with IEx.pry/0
is reached the program will stop and you have the chance to inspect. It is like a breakpoint in a traditional debugger.
When you are finished just type respawn
into the console.
require IEx;
defmodule Example do
def double_sum(x, y) do
IEx.pry
hard_work(x, y)
end
defp hard_work(x, y) do
2 * (x + y)
end
end