foreach loop
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 19 07:40:33 PDT 2015
V Mon, 19 Oct 2015 14:28:03 +0000
Namal via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsáno:
> 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;
> }
I am not sure what you exactly want, but you can break foreach
statement:
int [] g = [9,15,21];
int [] v = [2,3,5,7,8,9,11,13,17,19];
outerfor: foreach(j;1..10)
for(int i = 0; v[i]<j;++i){
do something;
if (iWantToBreak)
break outerfor;
}
More information about the Digitalmars-d-learn
mailing list