Clean solution for dropping into REPL console in the middle of program execution

前端 未结 2 664
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 02:24

Is there any working solution for dropping into REPL console with for Scala 2.10?

This is mainly for debugging purpose - I want to pause in the middle of execution, and

2条回答
  •  盖世英雄少女心
    2021-02-14 03:01

    I was looking at this recently and found Ammonite to be a sufficient solution for my needs.

    1. Add Ammonite to your library dependencies: libraryDependencies += "com.lihaoyi" % "ammonite" % "1.6.0" cross CrossVersion.full
    2. Invoke Ammonite where you want to drop to the REPL shell: ammonite.Main().run()

    Note that you have to pass any variables you want bound inside of run, e.g. run("var1" -> var1). Have a look at their example - Instantiating Ammonite.

提交回复
热议问题