-1

what is the shortest ( nr. LoC) & fastest ( Performance) method to copy arrays with this array definition

Type  TPointSet = Array [1 .. 300] of TPoint;


 var  set1, set2 :  TPointSet;


 set2 := set1; //  not working , no compiler error

I don't want to loop my array and copy each item , any better option?

1

1 Answer 1

2

Like Andreas says,

set2 := set1;

does work (if defined as in your question). What makes you think it doesn't?

What it needs to work is that both set1 and set2 must be defined as the same type identifier, not only as the same type.

This means that

 var  set1 : Array [1 .. 300] of TPoint;
      set2 : Array [1 .. 300] of TPoint;

 set2 := set1; //  not working , compiler error

will fail, as they are of the same type but not of the same type identifier. The difference here is between type (which can be multiple words/tokens) and identifier (which is always a single word/token).

(There are some cases that works despite not being typed as identical identifier, but for the most part, if you want to make a type assignment compatible between different variables of that type, you should define a specific type identifier for that type and use it on all variables that you need to be able to be assignment compatible with each other).

1
  • found issue on unexpected part of my code , thanks for comments
    – Franz
    Jun 9 at 20:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.