简体   繁体   English

如何在 Kotlin REPL 中加载文件

[英]How to load a file in Kotlin REPL

According to :help in Kotlin REPL I can load a file by load: command.根据 Kotlin REPL 中的:help我可以通过load:命令加载文件。

>>> :help
Available commands:
:help                   show this help
:quit                   exit the interpreter
:dump bytecode          dump classes to terminal
:load <file>            load script from specified file

But loading the file fails like this.但是加载文件会像这样失败。 The Rational.kt exists current directory. Rational.kt存在当前目录。

>>> load: "Rational.kt";
error: unexpected tokens (use ';' to separate expressions on the same line)
load: "Rational.kt";

Neither load: Rational.kt nor load: "Rational.kt" works. load: Rational.ktload: "Rational.kt"都不工作。 How can I load a file in REPL?如何在 REPL 中加载文件? I couldn't find an example for it.我找不到它的例子。

尝试不使用引号:

>>> :load Rational.kt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM