Posted By

mkluwe on 04/13/10


Tagged

function exec loadstring


Versions (?)

execute string


 / Published in: Lua
 

yields the interpreted value of a given string by prepending "return" and calling loadstring()

  1. local function exec( s )
  2. return loadstring( 'return ' .. s )()
  3. end
  4.  
  5. -- example:
  6. local v = exec '{ 42 }'
  7. print( v[ 1 ] ) -- prints "42"

Report this snippet  

You need to login to post a comment.