Search code examples
kotlinread-eval-print-loop

How to load a file in Kotlin REPL


According to :help in Kotlin REPL I can load a file by load: command.

>>> :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.

>>> 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. How can I load a file in REPL? I couldn't find an example for it.


Solution

  • Try without the quotes:

    >>> :load Rational.kt