Hello.

Let's say I have a type:

TClothingType = (ctJacket, ctPants, ctShirt);

and I want to associate it with color:

var
  Colors: array[TClothingType] = (clRed, clBlue, clGreen);

Is it possible to protect Colors against a change in order of items in
TClothingType? Adding or removing items from TClothingType will
generate error that too much/not enough initializers are present. But
if someone changes the order of items or changes a clothing type to
different I will get wrong association of colors.

I'm thinking of syntax like this:

var
  Colors: array[TClothingType] = (ctJacket:clRed, ctPants:clBlue,
ctShirt:clGreen);

Is something like this possible?

I know I can assign it at runtime:

Colors[ctJacket] := clRed;
Colors[ctPants] := clBlue;
Colors[ctShirt] := clGreen;

But I'm looking for compile time method.

--
cobines
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to