If I am creating an arithmetic problem solving app...
# getting-started
r
If I am creating an arithmetic problem solving app, is it a bad idea to use an eval function to have Kotlin evaluate the result of an expression, like
Copy code
import javax.script.ScriptEngineManager

fun main() {
    val engine = ScriptEngineManager().getEngineByName("kotlin")
    val result = engine.eval("2 + 2 == 4")
...
? This is to avoid having to implement my own recursive expression parser
c
Yes, it is a very bad idea. If you do this, your users will be able to execute arbitrary Kotlin code, not just expressions. If that's what they want, they should just use
ki
You may be interested in https://github.com/notKamui/Keval