Hello!
Simple using of delegates:

===========
#!/usr/bin/rdmd
import std.stdio;

void main()
{
    void delegate() functions[];

    foreach (i; 0..10)
    {
        void print()
        {
            writefln("%s", i);
        }

        functions ~= &print;
    }

    foreach (i; 0..10)
    {
        functions[i]();
    }
}
=============

Prints
$ ./delegates.d
9
9
9
9
9
9
9
9
9
9

How to print 0..9?

Reply via email to