Open khchen opened 2 years ago
compile can compile the source code into a closure at runtime time. Example:
compile
message = "Metaprogramming" value = 12345 code = " def test return $value end print('$message') return test() " func = compile(code) print(func())
Output:
Metaprogramming 12345
eval can evaluate an expression and returns the result. Example:
eval
message = eval("'Meta' + 'programming'") value = eval("123450 / 10") func = eval(" fn print(message) return eval('value') end ") eval("print")(eval("func()"))
compile
can compile the source code into a closure at runtime time. Example:Output:
eval
can evaluate an expression and returns the result. Example:Output: