In ruby Ctrl - d
allows to resume the execution of the code after reaching a binding.pry
.
What is the equivalent in Elixir for IEx.pry
?
As documented in IEx.pry/0
, you can call respawn
to resume the execution.
This is useful for debugging a particular chunk of code when executed by a particular process. The process becomes the evaluator of IEx commands and is temporarily changed to have a custom group leader. Those values are reverted by calling
IEx.Helpers.respawn/0
, which starts a new IEx shell, freeing up the pried one.
iex(1)> defmodule A do
...(1)> require IEx
...(1)> def a do
...(1)> a = 1
...(1)> b = 2
...(1)> IEx.pry
...(1)> IO.puts a + b
...(1)> end
...(1)> end
{:module, A,
<<70, 79, 82, 49, 0, 0, 12, 144, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 110,
0, 0, 0, 12, 8, 69, 108, 105, 120, 105, 114, 46, 65, 8, 95, 95, 105, 110,
102, 111, 95, 95, 9, 102, 117, 110, 99, ...>>, {:a, 0}}
iex(2)> A.a
Break reached: A.a/0 (iex:6)
pry(1)> a
1
pry(2)> b
2
pry(3)> respawn
Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help)
3
:ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With