Elixir:到达IEx.pry后恢复代码执行 [英] Elixir: Resume code execution after reaching IEx.pry

查看:78
本文介绍了Elixir:到达IEx.pry后恢复代码执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ruby中, Ctrl-d 允许在达到 binding.pry 之后恢复代码的执行。
IEx.pry 在Elixir中等效吗?

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 ?

推荐答案

IEx.pry / 0 ,您可以调用 respawn 恢复执行。


在调试由特定进程执行的特定代码块时很有用。该过程将成为IEx命令的评估者,并且会暂时更改为具有自定义组负责人。通过调用 IEx.Helpers.respawn / 0 还原这些值,这将启动一个新的IEx shell,从而释放撬出的外壳。

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

这篇关于Elixir:到达IEx.pry后恢复代码执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆