getters and setters not an lvalue

Regan Heath regan at netmail.co.nz
Wed Oct 31 07:15:05 PDT 2012


On Wed, 31 Oct 2012 14:08:18 -0000, maarten van damme  
<maartenvd1994 at gmail.com> wrote:

> Ok, looking forward to the fix :)
>
> Btw, I have a foreach loop and in that foreach loop I want to decide
> if the current element can stay and if not, I want to remove it. If
> removing it yields an empty range in the foreach loop, it crashes.
> What's the sane way to do this?

Altering the thing you're "foreach"ing over is generally frowned upon  
because it causes issues like this.  Ideally D would const-ify the thing  
you're foreaching inside the body of the foreach to prevent it.  Usually  
you end up using "for" and an index value instead.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list