将 Scala 文件加载到解释器中以使用函数? [英] Load Scala file into interpreter to use functions?

查看:22
本文介绍了将 Scala 文件加载到解释器中以使用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件中定义了一些 Scala 函数,而不是在类中,我想在 Scala 解释器中使用它们.我知道我可以说 scala filename.scala 来简单地运行文件并退出解释器,但我想运行文件然后留在解释器中以便我可以做一些测试.谁能告诉我如何简单地将文件加载到解释器中,以便我可以使用其中定义的函数?

I have some Scala functions defined in a file, not in a class, and I would like to use them in the Scala interpreter. I know I can say scala filename.scala to simply run the file and exit the interpreter, but I would like to run the file and then stay in the interpreter so I can do some testing. Can anyone tell me how to simply load a file into the interpreter so I can use the functions defined within it?

推荐答案

type :load/path/to/file in Scala REPL.

type :load /path/to/file in Scala REPL.

您可以通过键入 :help

这篇关于将 Scala 文件加载到解释器中以使用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆