Does the kotlin REPL have code completion?

512 Views Asked by At

I just opened kotlinc (which apparently defaults to kotlin-jvm ?) and dropped in some hello-world type code:

data class Person(val name: String, val age: Int) {
   val isAdult get() = age >= 20
}

Let's create an instance :

val p = Person("ab", 10)

Hopefully the repl will offer us the properties via tab key .. ?

p.<tab>

The repl beeps on each tab instead of offering the properties of that Person instance. "Just in case" I :quit and opened kotlinc-jvm explicitly - and got the same behavior. Is it to be believed that there were no code completion available? Am I missing some option to starting kotlinc ?

2

There are 2 best solutions below

1
On BEST ANSWER

Update: JetBrains has now released ki, which supports auto completion (and more).

The kotlin repl currently does not support tab completion. See the official bug tracker for more details: https://youtrack.jetbrains.com/issue/KT-14177, https://youtrack.jetbrains.com/issue/KT-23036

If you use IntelliJ, you may want to try out scratch files. They work well for small bits of code and support code completion.

0
On

Intellij Kotlin-REPL does have code completion. It makes a ton of sense to use the IDE coming from the creators of the language JetBrains.

enter image description here

enter image description here