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


Frits van Bommel <fvbom...@wxs.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Frits van Bommel <fvbom...@wxs.nl>  2009-05-11 16:59:18 PDT 
---
(In reply to comment #0)
> Either I'm doing something dumb, or I've found a bug where a string gets
> trashed between storing it as key in an associative array and then getting it
> back out.

I'm afraid it's the former.

>From the InputStream.opApply() documentation at
<http://www.digitalmars.com/d/1.0/phobos/std_stream.html>:
"The string passed in line may be reused between calls to the delegate." 

This means you can't keep a copy of a line around after the current iteration
without duplicating it, because it'll get overwritten.
Changing the last line of your file-reading loop to "data[line.dup]++;" fixes
the problem you're seeing.

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

Reply via email to