Re: Function Addresses?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Function Addresses?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2006年6月13日 12:26:47 -0300
> Why would it be desired to have a new anonymous function created for
> each call?
>
> function a()
> return function () end
> end
Because the function statement creates closures. Try this:
function add(x)
return function(y) return x+y end
end
add10=add(10)
add20=add(20)
print(add10(3),add20(3))
--lhf