canFind typing
bearophile
bearophileHUGS at lycos.com
Thu Nov 29 11:15:20 PST 2012
Jonathan M Davis:
> Why wouldn't they be? You can compare int and double, and
> that's what find and canFind care about.
Right, it's a matter of equality operator.
In my code I was performing canFind on an array of tuples. So I
didn't realize that the following code (where both tuple field
type and field name are different) is accepted in D (probably I
am getting used to the higher type strictness of functional
languages):
import std.typecons: Tuple;
alias T1 = Tuple!(int, "x");
alias T2 = Tuple!(double, "y");
void main(string[] args) {
assert(T1(1) == T2(1));
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list