我有:
sum.scala
def sum(a : Int, b : Int) = println(a+b)
我想从CLI调用该函数 做类似的事情:
scala sum.scala.sum(3, 4)
这甚至可能吗?如果是这样的话,我需要在CLI中输入以使其工作的命令的语法是什么?
我想在不创建包装函数的对象的情况下这样做。
答案 0 :(得分:3)
运行scala -help
以查看CLI选项。
您需要的选项是:
-i <file> preload <file> before starting the repl
-e <string> execute <string> as if entered in the repl
示例:
> scala -i sum.scala -e "sum(3, 4)"
7