3

I have this type:

type
  TFieldRec = array of record
    FieldName: string;
    Value: Variant;
    DataType: TFieldType;
    Data: Pointer;
  end;

And the code:

var
  FR: TFieldRec;
SetLength(FR, 5);

My question: is it guaranteed that each record element will be initialize with default values?

'', Unassigned, ftUnknown, nil

In the debugger I can see it is true. But I remember records should be initialized with Initialize (or is it Finalize?)

1
  • True. Will delete Commented Nov 26, 2018 at 11:24

1 Answer 1

8

My question: is it guaranteed that each record element will be initialized with default values?

Yes, this is guaranteed.

The SetLength documentation says (my emphasis):

Existing elements in the array are preserved and newly allocated space is set to 0 or nil.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.