Error when using delegate in foreach

Karen Lanrap karen at digitaldaemon.com
Tue Oct 17 16:57:46 PDT 2006


Max Samuha wrote:

> What am I doing wrong?

Semms you mean something like this:

import std.stdio;

void main()
{
        auto dg = delegate (int delegate( inout int) dgp)
		{
                        static int j=0;
                        int res=0;
                        while( j < 15){
                                j++;
                                res= dgp(j);
                                if(res) break;
                        }
			        return res;
		};

	foreach (int i; dg)
	{
		writefln(i);
	}
}



More information about the Digitalmars-d-learn mailing list