How to save REPL session?

后端 未结 2 1628
无人共我
无人共我 2021-01-02 05:02

Is it possible to save a REPL session in a file? Is there a minimum version of Scala requiered to do this? I remember having seen someone do it, but I can\'t fine it in :hel

2条回答
  •  一个人的身影
    2021-01-02 05:11

    Note that you have in addition of the native Scala REPL the shell-scripting project Ammonite, which does have a Save/Loadd Session feature:

    Apart from plain saves and loads, which simply discard everything after the most recent save, you can also provide a name to these functions.
    That lets you stop working on a branch, go do something else for a while, and be able to come back later to continue where you left off:

    @ val (x, y) = (1, 2)
    x: Int = 1
    y: Int = 2
    
    @ sess.save("xy initialized")
    
    @ val z = x + y
    z: Int = 3
    
    @ sess.save("first z")
    
    @ sess.load("xy initialized")
    
    @ val z = x - y
    z: Int = -1
    

提交回复
热议问题