[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Indirect function call
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 6 May 2011 10:21:39 -0300
> 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)()
print(tostring(result))
end