public static native eval(code as String) as Object throws SyntaxError, TypeError, Exception
Compiles and executes a Klyn script provided as a string. The supplied String is executed as-is, without additional reindentation. Triple-quoted literals remove their common margin when the String is created.
Evaluation retains the caller's lexical values, imports and declared types, including types declared by an enclosing eval. Declarations remain local to that evaluation. Thrown exceptions retain their object identity, fields and stack when crossing an eval boundary. In contrast, compile() validates an autonomous fragment with the caller's imports only.
| Parameter | Description |
|---|---|
code | Klyn source code to compile and execute. |
result = Application.eval("40 + 2")
print(result)