hacks on opApply
monkyyy
crazymonkyyy at gmail.com
Thu Sep 10 08:10:42 UTC 2026
On Thursday, 10 September 2026 at 07:59:05 UTC, Meta wrote:
> On Wednesday, 27 August 2025 at 20:34:22 UTC, monkyyy wrote:
>> spec doesn't define this behavior as far as I can tell
>>
>> ```d
>> import std;
>> auto loop(){
>> struct foreach_{
>> int opApply(int delegate(int i) dg){
>> dg(0).writeln;//1
>> dg(1).writeln;//2
>> dg(2).writeln;//3
>> return 3;
>> }}
>> return foreach_();
>> }
>> unittest{
>> a: while(true){
>> b: foreach(i;loop()){
>> if(i==0){break;}
>> if(i==1){break b;}
>> if(i==2){break a;}
>> }}}
>> ```
>
> What about continue? Does it work and return a value? Going off
> what Steven said, I assume it'd be 0.
probably, its been a while
More information about the Digitalmars-d
mailing list