I forgot to ask, what version of DMD are you using?<br><br><div class="gmail_quote">2010/12/24 Mariusz Gliwiński <span dir="ltr"><<a href="mailto:alienballance@gmail.com">alienballance@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Friday 24 December 2010 @ 06:24:34 Caligo:<br>
<div><div></div><div class="h5">> Greetings,<br>
><br>
> I just joined here, so sorry if this has been posted before.<br>
><br>
> I'm reading TDPL and the example on page 8 doesn't compile.  I'm using the<br>
> latest GDC with GCC 4.4.5.  I've checked the errata, but nothing for this<br>
> error.<br>
><br>
> import std.stdio;<br>
> import std.string;<br>
><br>
> void main(){<br>
><br>
>      size_t[char[]] dictionary;<br>
>     foreach(line; stdin.byLine()){<br>
>               foreach(word; splitter(strip(line))){<br>
>                           if(word in dictionary) continue;<br>
>                     auto newID = dictionary.length;<br>
>                           dictionary[word] = newID;<br>
>                     writeln(newID, '\t', word);<br>
>             }<br>
>     }<br>
>     //writeln(dictionary.length);<br>
> }<br>
><br>
><br>
> This is the error:<br>
> dictionary.d:12: Error: associative arrays can only be assigned values with<br>
> immutable keys, not char[]<br>
><br>
> If i use immutable keys, it works, but it defeats the purpose.  So what's<br>
> wrong with the code?<br>
<br>
</div></div>It works for DMD, I think it's a GDC bug (i'm new in D too, so i might be<br>
wrong). Keep in mind that GDC implements only D 1.0 and book has D 2.0 code.<br>
<br>
Sincerely,<br>
<font color="#888888">Mariusz Gliwiński<br>
</font></blockquote></div><br>