On Thu, Jul 5, 2012 at 3:36 PM, bearophile <[email protected]> wrote:

> lijie:
>
>
>  import std.stdio;
>>> void main() {
>>>     void delegate()[] functions;
>>>     foreach (i; 0 .. 5) {
>>>         functions ~= {
>>>             printf("%d\n", i);
>>>         };
>>>
>>
>>     }
>>
>>>     foreach (func; functions) {
>>>         func();
>>>     }
>>> }
>>>
>>
>
> import std.stdio;
>
> void main() {
>     void delegate()[] functions;
>
>     foreach (i; 0 .. 5)
>         functions ~= ((int j) => { printf("%d\n", j); })(i);
>
>     foreach (func; functions)
>         func();
> }
>
>
Thanks bearophile.

Best regards,

-- Li Jie

Reply via email to