A beginner's question of foreach

Alex faint_u at 163.com
Sat Dec 29 05:14:59 PST 2007


The code snippet from the document page of std.stream can't pass compile:
InputStream s = new BufferedFile(file);

foreach(ulong n, string line; s)
{
	writeln(line);
}

The following are error message:
D:\Tools\d\dmd>dmd cat.d
cat.d(11): function std.stream.InputStream.opApply (int delegate(ref char[] line)) does not match parameter types (int delegate(ref ulong __applyArg0, ref invariant(char)[] __applyArg1))cat.d(11): Error: cannot implicitly convert expression (__foreachbody9) of typeint delegate(ref ulong __applyArg0, ref invariant(char)[] __applyArg1) to int delegate(ref ulong n, ref wchar[] line)


Any idea? The document needs update?



More information about the Digitalmars-d mailing list