Import multiple packages in Scala REPL

前端 未结 1 1568
野趣味
野趣味 2020-12-16 18:02

In Scala, I frequently have to import multiple packages worth of implicits and other utilities, particularly on the REPL:

import scala.collection.JavaConvers         


        
相关标签:
1条回答
  • 2020-12-16 18:38

    I'm not sure of a general solution, but in SBT it's possible to configure the project so that the console (REPL) runs some initial commands upon launching. Here's an excerpt from an example build.sbt file,

    // set the initial commands when entering 'console' only
    initialCommands in console := "import myproject._"
    

    Edit: Another reference is the Scalala project. They have a Scala program that launches an embedded REPL and fills in the necessary imports. For usage, see their quick-start guide.

    0 讨论(0)
提交回复
热议问题