Hello Community,
At the moment, I have two functions, which are able to add and evaluate a lambda from a MutableList.
Now, I want to save this List to a file in a human-readable format and later load them again and evaluate the lambdas.
What is the best approach? Can I use JSON to save them? And edit them externaly.
I want to avoid the ScriptEngine because I'm using linux aarch as host so kotlin/native did not work nor is the jna library compatible.
Here is my code so far:
typealias func = ()-> Unit
@JvmField val command = mutableListOf<func>()
fun main() {
add {
val i =4
println("${i}")
}
eval(command[0])
}
fun add(action: () -> Unit): Unit {
command.add(action)
}
fun eval(action: () -> Unit) {
action()
}
Thank you