DelphiTools – In Delphi you can initialize a dynamic array in two ways, either manually or via the Create magic constructor: type TIntegerArray = array of Integer; procedure Test; var a : TIntegerArray; begin // magic constructor a := TIntegerArray.Create(1, 2); // manual creation SetLength(a, 2); a := 1; a := 2; end; The outcome in both cases is the same, are all things equal? Some array initializations are more equal than others The first method is less verbose in code, but quite a bit less efficient, if you check the CPU view, that becomes obvious TestUnit.pas.32: a := ...
Visits by Source
Users who voted for this posting
Jordi Coll Corbilla
Jørn E. Angeltveit