Ki is not the only interactive shell to be available for Kotlin. Rather, it tries to overcome the limitations of existing Kotlin interactive shells, as JetBrains engineer Pasha Finkelshteyn explains:
Ki supports autocompletion, aimed to simplify access to Kotlin collection API; external dependencies, thanks to a special
:dependsOn construct that loads a dependency from Maven Central and makes it available locally; and type inference, with the added bonus of a built-in
t command which is able to show the type of any given expression.
ki provides a special paste mode to better handle large code snippets. This mode can be enabled by executing the command
:paste, which makes the REPL able to swallow whole chunks of code that are immediately interpreted and can be referenced later.
Another interesting features of
ki is scripting support, which enables saving a session to disk and load it back using the
:l command. After loading a script, the
:ls command will show you a list of all imported symbols, including functions, classes, variables, etc. This is especially useful to spare oneself the chore of loading all required dependencies each time, says Finkelshteyn.
import java.net.* fun sendGet(address: