Why can't I use TArray<string> as a class constant?

Viewed 350

When I try and use an array constant inside a class then I get the following error:

[dcc32 Error] TestConstants.dpr(14): E2086 Type 'TArray<T>' is not yet completely defined

The same code compiles fine when I use it as a global constant or when I use array of string instead of TArray. Is there a trick to getting this working?

program Project98;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

type
  TMyTestClass = class
  strict private
    const
      TEST_CLASS_CONSTANT: TArray<String> = ['1','2']; // <-- Error here
      TEST_CLASS_CONSTANT2: array of string = ['1','2']; // <-- No error
  end;

const
  TEST_GLOABL_CONSTANT: TArray<String> = ['3','4']; // <-- No error
  TEST_GLOBAL_CONSTANT2: array of string = ['3','4']; // <-- No error
begin
end.
0 Answers
Related