How can evaluate Kotlin expressions?


#1

Hello!

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
exeutor.run(kotlinCode)

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


#2

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