Foreach problem

Tim M a at b.com
Sun Jan 11 01:29:16 PST 2009


On Sun, 11 Jan 2009 21:39:55 +1300, Denis Koroskin <2korden at gmail.com>  
wrote:

> On Sun, 11 Jan 2009 11:04:38 +0300, Tim M <a at b.com> wrote:
>
>> On Sun, 11 Jan 2009 20:31:51 +1300, Denis Koroskin <2korden at gmail.com>  
>> wrote:
>>
>>
>>>> Yep that probibly is a slight bug. What I would like to know is why  
>>>> cant I do foreach with primitive types like I can with objects.
>>>
>>> You can use foreach to iterate over arrays and tuples, if that's what  
>>> you mean. Iterating over over primitive types makes little sense.
>>
>>
>> Just re reading my own question I think it is clear what I meant. I  
>> meant array of primitives so yes iterating over an array, but an array  
>> of primitives. Dmd handles foreach over SomeObject[] a lot more relaxed  
>> than int[].
>>
>>
>
> Example, please? I never noticed any difference.

Ok just did another test. Objects are handled the same way like you said.  
The "problem" is actually in the opApply where it can work just fine (runs  
ok not just compiles ok) using the exisiting variable.



More information about the Digitalmars-d-learn mailing list