Is it possible do Declare a constant array that includes another constant array?

后端 未结 4 1688
天涯浪人
天涯浪人 2021-01-21 15:49

I want to do something like this:

const

  MyFirstConstArray: array[0..1] of string = (\'Hi\', \'Foo\');
  MySecondConstArrayWhichIncludesTheFirstOne: array[0..2         


        
4条回答
  •  萌比男神i
    2021-01-21 16:47

    If order isn't relevant, then use enumerated sets.

    type
      TMyConsts = (tConstFoo, tConstHi, TConstBar);
    const
      MyFirstConstSet = [tConstFoo, tConstHi];
      MySecondConstSet = MyFirstConstSet + [TConstBar];
      MyConstStrings: array[TMyConsts] of string = ('Foo', 'Hi', 'Bar');
    

    You can use the MyConstStrings array to resolve your enumerations into strings if you want. Depends on your objective.

提交回复
热议问题