Search code examples
kotlinjsr223

Using bindings in Kotlin Script (Jsr 223)


I try to follow this example to embed a Kotlin Script. But if try to use the bindings map in my script

val unit = bindings["unit"] as Entity

I get a syntax error (unresolved reference of bindings) and cannot compile the project (in Intellij I created a kts file for the script). How can I resolve this ?


Solution

  • In the current version on Kotlin you no longer need to use the bindings map. Just access it as a normal variable (unit).