Error when using delegate in foreach

Max Samuha maxter at i.com.ua
Wed Oct 18 00:23:05 PDT 2006


On Tue, 17 Oct 2006 23:57:46 +0000 (UTC), Karen Lanrap
<karen at digitaldaemon.com> wrote:

>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);
>	}
>}

Yes, right. Thanks a lot



More information about the Digitalmars-d-learn mailing list