On Monday, 19 October 2015 at 14:43:04 UTC, Rikki Cattermole wrote:
On 20/10/15 3:28 AM, Namal wrote:
Is it possible to create a foreach loop with a breakstetemen?

I mean something like that for the second loop where i want to break if
element from:

int []  g = [9,15,21];
int [] v = [2,3,5,7,8,9,11,13,17,19];

foreach(j;1..10)
for(int i = 0; v[i]<j;++i){
  do something;
}

If you want to break a specific loop, use labels.

L1:
        foreach(i; 0 .. 10) {
        
        L2:     foreach(j; 0 .. 10) {
                        // break L1;

                        // break L2;
                        // or
                        // break;
                }
        }

Hey thanks, until now I just used bool variables as break flags.

Reply via email to