Delphi Compiler Error
E2072 Number of elements (%d) differs from declaration (%d)
Reason for the Error & Solution
This error message appears when you declare a typed constant or initialized variable of array type, but do not supply the appropriate number of elements.
program Produce; var AÂ : array [1..10] of Integer = (1,2,3,4,5,6,7,8,9); begin end.
The example declares an array of 10 elements, but the initialization only supplies 9 elements.
program Solve; var AÂ : array [1..10] of Integer = (1,2,3,4,5,6,7,8,9,10); begin end.
We just had to supply the missing element to make the compiler happy. When initializing bigger arrays, it can be sometimes hard to see whether you have supplied the right number of elements. To help with that, you layout the source file in a way that makes counting easy (e.g. ten elements to a line), or you can put the index of an element in comments next to the element itself.