Error using `equal` with various string types

monarch_dodra monarchdodra at gmail.com
Sun Feb 24 03:24:21 PST 2013


On Sunday, 24 February 2013 at 04:47:41 UTC, Jonathan M Davis 
wrote:
> However, now that I think about it, equal takes a predicate, so 
> it would
> probably work to do something like
>
> equal!"equal(a, b)"(["hello"d], ["hello"]);
>
> - Jonathan M Davis

Yes, and you don't even need to use a mixin.

This is a known "issue", and is specifically covered and 
"pseudo-documented" the source unittests.

Copy pasted straight from the source:

//Should not compile, because "string == dstring" is illegal
static assert(!is(typeof(equal(["hello", "world"], ["hello"d, 
"world"d]))));
//However, arrays of non-matching string can be compared using 
equal!equal. Neat-o!
equal!equal(["hello", "world"], ["hello"d, "world"d]);


More information about the Digitalmars-d-learn mailing list