(let [nashorn (-> (javax.script.ScriptEngineManager.)
(.getEngineByName "nashorn"))]
(.eval nashorn "print('hello')"))
;; => nil
;; and doesn't print `hello`
(let [nashorn (-> (javax.script.ScriptEngineManager.)
(.getEngineByName "nashorn"))]
(.eval nashorn "var a = 1")
(.eval nashorn "a + 2"))
;; => 3.0
(let [nashorn (-> (javax.script.ScriptEngineManager.)
(.getEngineByName "nashorn"))]
(.eval nashorn "function plus1(n){ return n + 1; }")
[(.invokeFunction (cast javax.script.Invocable nashorn) "plus1"
(into-array Object [3]))
(.invokeFunction (cast javax.script.Invocable nashorn) "plus1"
(into-array Object ["3"]))])
;; => [4.0 "31"]