Startup script for scala REPL

筅森魡賤 提交于 2019-12-04 04:58:02

问题


What is the name of startup script for the scala REPL. For example something along the lines of the following:

~/.scalarc 

回答1:


You could try something like:

$ alias scala='scala -i ~/.scalarc '

Note the trailing space—if you omit it your alias will disregard parameters.

Further use of 'scala' (once the alias is defined) will work as expected for REPL. If you use the alias for launching compiled programs, '~/.scalarc' will simply be ignored.

edit: It seems using '-i' in this way causes a significant slowdown.
The following, though somewhat convoluted (warning: bashism ahead), works faster:

$ scala -i <( cat ~/.scalarc foo.scala)

This concatenates your code (e.g. 'foo.scala') with '.scalarc' and evaluates everything on startup, leaving you at the REPL.
I don't think it's a satisfactory solution, but worth mentioning.



来源:https://stackoverflow.com/questions/19883770/startup-script-for-scala-repl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!