Hello. I have the following d code which fails to compile. All 3 initializations of mywords fail. What am I doing wrong?
thanks. $ dmd --help Digital Mars D Compiler v2.042 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html Usage: import std.algorithm, std.stdio, std.string; //uint[string] mywords = [ "Hello" : 1, "World" : 1, "Cat" : 1, "Dog" : 1 ]; //auto mywords = [ "Hello" : 1, "World" : 1, "Cat" : 1, "Dog" : 1 ]; const uint[const string] mywords = [ "Hello" : 1, "World" : 1, "Cat" : 1, "Dog" : 1 ]; void main() { foreach( line; stdin.byLine()) { foreach( word; split(strip(line))) { string s = word.idup; if( s in mywords) writefln( "%s is a word I know.", s); else writefln( "%s is not a word I know.", s); } } return; }