var
arr: array of LongInt;
begin
arr := [1, 2, 3, 4];
end.
I don't have fpc ver 3.20 to test it, but that is interesting. I like the idea of being able to assign multiple array values at once. Very useful for short arrays.
So does that line: "arr:=[1,2,3,4];" do the equivalent of a setLength(arr,4) and then initialize the array with the data values?
Just wondering what happens if you use that construct to not only initalize arr, but also to assign new values to it during run time. Say for example the following. Would the second arr:=[...] construct create a new array, or would it just modify the values in the existing array?
var arr: array of LongInt;
begin
arr := [1, 2, 3, 4];
// .... do something with arr
arr := [5, 6, 7, 8];
// ... do something else with arr
end.