On Mon, Jan 23, 2012 at 01:26:44PM -0800, Ali Çehreli wrote:
> On 01/23/2012 01:16 PM, H. S. Teoh wrote:
[...]
> >     struct Test {
> >             int opApply(int delegate(ref int) dg) {
> >                     auto ret = 0;
> >                     for (auto i=0; ret==0&&  i<5; i++) {
> >                             ret = dg(i);
> 
> Add:
> 
>     if (ret) {
>        break;
>     }
> 
> ret is non-zero if the foreach body contains a break statement.
[...]

Actually I already put that into the loop condition. But yes, the return
value needs to be checked.


T

-- 
If Java had true garbage collection, most programs would delete
themselves upon execution. -- Robert Sewell

Reply via email to