lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> indirect("afunc(x)")
> afunc(42) called
> nil
> Can anybody explain why the output is nil instead of 42?

Because you did not return anything in the call. Try
	indirect("return afunc(x)")

Or add "return" automatically inside indirect before calling loadstring:

 function indirect(str)
     local result = loadstring("return "..str)()