[Issue 9437] unwanted behavior from phobos range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 1 06:00:05 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9437


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #1 from monarchdodra at gmail.com 2013-02-01 06:00:04 PST ---
This works as intended, and is the documented behavior of foreach.

foreach is supposed to be used on the elements only. You cannot add, remove, or
interface with the range in general during a foreach. If you need a more
specific behavior, just use a for:

void main( string[] args ){
    R r = R( "Hello D users" );
    for( ; !r.empty ; r.popFront() )
    {
        auto l = r.front;
        writeln( l, ", ", r.front() );
    }
}

Please see the thread in regards to the mm file thing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list