调用scala脚本函数

调用scala脚本函数,scala,Scala,我有: sum.scala def sum(a : Int, b : Int) = println(a+b) 我想从CLI调用该函数 通过这样做: scala sum.scala.sum(3, 4) 这可能吗?如果可能的话,我需要在CLI中键入什么样的命令语法才能使其正常工作 我不想创建对象来包装函数。运行scala-help查看CLI选项 您需要的选项有: -i <file> preload <file> before starting the repl -

我有:

sum.scala

def sum(a : Int, b : Int) = println(a+b)
我想从CLI调用该函数 通过这样做:

scala sum.scala.sum(3, 4) 
这可能吗?如果可能的话,我需要在CLI中键入什么样的命令语法才能使其正常工作


我不想创建对象来包装函数。

运行
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