Is TArray<T>.Create() documented somewhere?
It was just by chance when I found out that a con开发者_Python百科struct like this actually compiles and produces the desired result:
var
Arr: TArray<Integer>;
begin
Arr := TArray<Integer>.Create(100, 101, 102);
end;
I only tested it in Delphi XE, but it may work in older versions, too. Is this documented somewhere?
It's documented in the language guide.
It's a generic version of the following, which works as far back as Delphi 2007:
type
TIntArray = array of Integer;
var
MyIntArray: TIntArray;
begin
MyIntArray := TIntArray.Create(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
...
end;
It's finally a solution to being able to initialize an array without knowing the size first.
精彩评论