When you call Create, you need to call Free afterwards to prevent memory leaks.
Though not for arrays, Create is a really bad name for array creation
Tell that the Delphi devs... I'm glad that they saw reason later on and allowed the
[ … ] syntax.
as well as:
SomeArrayVar.Create(value1, value2); // variable NOT type!
The following also compiles. Always has. It's only that T is nil that it will crash (but otherwise the effect is the same, calling Create constructor of an object, which you never want to do like this).
var
T: TObject;
begin
T.Create; // <-- compiles
But that is not the same. In an object that is called like a regular method in this case (allowing you to change the state of the object) and if some object field should be accessed inside that method while
T is
Nil, well, though luck.
The
Create for dynamic arrays
is no method however, it's a compiler intrinsic (and as
BeniBela said a really badly named one at that). It makes no sense at all to call it on a variable, because it does not allow you to change the state of the variable inside that constructor (no,
arr := arr.Create(v1, v2); does not count as "changing the state" in this case).
You are really trying me today, are you?
Me
Well, I'll refrain from any more comments if one post of me gets you so upset like that (look at what post).
No, it's the second time today. The first was
this post in this very same thread.