How come this works:

int[][] ta = [[2, 1, 4, 3], [3, 10, 2, 5]];
writeln(ta[1].maxElement); // 10

but I get an error when specifying the number of elements when declaring the array:

int[4][2] ta = [[2, 1, 4, 3], [3, 10, 2, 5]];
writeln(ta[1].maxElement); // get error on this line

Error: template std.algorithm.searching.maxElement cannot deduce function from argument types !()(int[4]), candidates are:
/home/samir/dlang/dmd-2.082.0/freebsd/bin64/../../src/phobos/std/algorithm/searching.d(3576):
        std.algorithm.searching.maxElement(alias map = (a) => a, Range)(Range r) if 
(isInputRange!Range && !isInfinite!Range)
/home/samir/dlang/dmd-2.082.0/freebsd/bin64/../../src/phobos/std/algorithm/searching.d(3583):      
  std.algorithm.searching.maxElement(alias map = (a) => a, Range, RangeElementType = 
ElementType!Range)(Range r, RangeElementType seed) if (isInputRange!Range && 
!isInfinite!Range && !is(CommonType!(ElementType!Range, RangeElementType) == void))

Thanks
Samir

Reply via email to