Iterating over containers of immutable objects

Justin Johansson no at spam.com
Wed Jun 30 02:46:04 PDT 2010


Jesse Phillips wrote:
> Justin Johansson Wrote:
> 
>> Steven Schveighoffer wrote:
>>> while(auto bar = iter.next())	// line 37
>>> {
>>>   ...
>>> }
>> Sorry that does not compile, dunno if it should I'm using
>> the latest D2.
> 
> I believe it needs to be written:
> 
> T bar;
> 
> while(bar = iter.next()) {
>     ....
> }

Yes it would be like you say if it were not for the immutable
disposition of the type T.  Rereading from the start of this
thread would explain this point.

Cheers, JJ


More information about the Digitalmars-d mailing list