just messing around in computercraft, trying to use a function as an argument but cant get it to work
bla = function() print("bla") end
execfunc = function(func) func() end
execfunc(bla())
I would like to do something as seen above, but with working code and not this nonsense
Drop the () from the argument to execfunc. You want to pass bla to execfunc not the result of calling bla().
> bla = function() return "bla" end
> execfunc = function(func) print(type(func)) end
> execfunc(bla())
string
> execfunc(bla)
function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With