I'd like to custom the scala repl by injecting some custom value when starting scala repl. What kind of api that I can use for that ? Any difference between scala 2.10 and 2.11 ? Thanks
How to inject custom object into scala repl when initializing scala repl
303 Views Asked by zjffdu At
3
There are 3 best solutions below
0
On
My solution was simply to define an alias in ~/.bashrc:
alias sc="scala -i ~/.scalarc"
I often use UUID objects from java.util package so it makes sense for me to predefine such import:
~/.scalarc:
import java.util.UUID
import scala.util.{Try, Success, Failure}
import scala.util.{Either, Left, Right}
You can use
scala -iorscala -Ito load the init file:so you can create your custom file when start, like creating
init.scalawith:and start
scala -i init.scalaand about the difference of
scala 2.10andscala 2.11, there should be no difference for this.