File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -695,7 +695,7 @@ $(GNAME OpApplyParameter):
695
695
)
696
696
697
697
$(P where each $(I OpApplyParameter) of `dg` must match a $(GLINK ForeachType)
698
- in a * ForeachStatement* ,
698
+ in a $(GLINK ForeachStatement) ,
699
699
otherwise the *ForeachStatement* will cause an error.)
700
700
701
701
$(P Any *ForeachTypeAttribute* cannot be `enum`.)
@@ -738,13 +738,18 @@ $(GNAME OpApplyParameter):
738
738
apply must return 0.)
739
739
)
740
740
741
+ $(P The result of calling the delegate will be nonzero if the *ForeachStatement*
742
+ body executes a matching $(GLINK BreakStatement), $(GLINK ReturnStatement), or
743
+ $(GLINK GotoStatement) whose matching label is outside the *ForeachStatement*.
744
+ )
745
+
741
746
$(P For example, consider a class that is a container for two elements:)
742
747
743
748
$(SPEC_RUNNABLE_EXAMPLE_RUN
744
749
--------------
745
750
class Foo
746
751
{
747
- uint[2 ] array;
752
+ uint[] array;
748
753
749
754
int opApply(scope int delegate(ref uint) dg)
750
755
{
@@ -763,10 +768,13 @@ $(GNAME OpApplyParameter):
763
768
import std.stdio;
764
769
765
770
Foo a = new Foo();
766
- a.array = [73, 82];
771
+ a.array = [73, 82, 2, 9 ];
767
772
768
773
foreach (uint u; a)
769
774
{
775
+ if (u < 5)
776
+ break;
777
+
770
778
writeln(u);
771
779
}
772
780
}
You can’t perform that action at this time.
0 commit comments