How can evaluate Kotlin expressions?



Imagine I have a text with some Kotlin code, which operates on variable a and b.

How can I run this code?

I. e. I mean following:

val kotlinCode:String = ... // kotlinCode contains the script to execute
val executor:KotlinCodeExecutor = KotlinCodeExecutor()
executor.bindings["a"] = someObject
executor.bindings["b"] = anotherObject

AFAIR you can do this in BeanShell and Java version of Ruby.

Is it possible to do this with Kotlin?

Thanks in advance

Dmitri Pisarenko


There is some active work on a scripting API for Kotlin.