Why uniq do not work with array of strings?

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 16 10:28:12 PST 2015


The question appear here
http://stackoverflow.com/questions/28546572/how-to-find-duplicates-in-array-of-strings-in-d

I can't understand, why uniq work for array of int but do not 
work with array of strings.

	int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
	writeln(uniq(arr));

	string [] str = ["qwe","asd","zxc", "qwe"];
	auto uniqarr = uniq(str);

	foreach(x;uniqarr)
	{
		writeln(x);
	}

Running .\test.exe
[1, 2, 3, 4, 5]
qwe
asd
zxc
qwe

^ "qwe" prints two times.


More information about the Digitalmars-d-learn mailing list