Kotlin's REPL interactive shell
Like two of the previous languages covered in this book, Scala and Clojure, Kotlin also has a REPL interactive shell that can be used to try Kotlin snippets interactively. As covered in the previous section, the REPL can be started by starting the compiler launch script without parameters (you can add the .bat extension on Windows, but this is not required):
kotlinc-jvm
Note
You can also choose to simply launch the kotlinc
launch script, as JVM is Kotlin's default compilation target.
The REPL shell implements a few built-in commands. In the Kotlin REPL, there's no need to call a Java class library method to exit the shell:
Command | Description |
| This shows a help screen containing the built-in REPL commands. |
| This is used to exit the REPL. |
| This dumps the Java bytecode of all the code generated during the current session in a readable text format. It is not useful to most end users but will be interesting to advanced developers who want to study... |