One way to look at foreach as not so bad

Bill Baxter wbaxter at gmail.com
Sun Oct 22 11:29:49 PDT 2006


Frits van Bommel wrote:
> Bill Baxter wrote:
> 
>> Julio César Carrascal Urquijo wrote:
>>
>>> I don't understand your point. You can already write something like:
>>>
>>> obj.each = (int i) {
>>>     writefln(i);
>>> };
>>>
>>
>> How do you set that up?  Something like this?
>>
>> class ObjClass
>> {
>>    class EachClass {
>>       void opAssign( void delegate(...) ) {
>>            [...]
>>       }
>>    }
>>    EachClass each = new EachClass();
>> }
>> ObjClass obj = new ObjClass();
> 
> 
> That won't work. There is no opAssign.

Oh yeh, that's right.  :-) I think "opAssign" must have looked familar 
to me merely because of previous discussions about its lack.

--bb



More information about the Digitalmars-d-announce mailing list