canFind typing
Jonathan M Davis
jmdavisProg at gmx.com
Thu Nov 29 10:49:40 PST 2012
On Thursday, November 29, 2012 15:28:56 bearophile wrote:
> I have used std.algorithm.canFind with different tuple types by
> mistake, and the compiler has not complained. So to show it I
> have written some reduced code that uses just numbers:
>
>
> import std.algorithm: canFind;
> void main() {
> int[] arr1 = [1, 2];
> double x1 = 2.0;
> assert(arr1.canFind(x1));
> double[] arr2 = [1.0, 2.0];
> int x2 = 2;
> assert(arr2.canFind(x2));
> }
>
>
> Are both of those canFind calls acceptable?
Why wouldn't they be? You can compare int and double, and that's what find and
canFind care about.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list