I'm writing a kind of array wrapper, using a record as container, and including some "class-like" functions to it. I also want the possibility to assign an array to it, as with a normal array, so I have implemented a Implicit class operator:
type
TArrayWrapper = record
class operator Implicit(AArray: array of TObject): TArrayWrapper; overload;
Items: TArray<TObject>;
procedure Add(AItem: TObject);
...
end;
So I can do things like:
procedure DoSomething;
var
myArray: TArrayWrapper;
begin
myArray := [Obj1, Obj2, Obj3];
...
end;
The problem appears when I try to pass an array of Integer to a method that has as parameter a TArrayWrapper:
procedure DoSomethingElse(AArrayWrapper: TArrayWrapper);
begin
...
end;
procedure DoSomething;
var
myArray: TArrayWrapper;
begin
myArray := [Obj1, Obj2, Obj3];
DoSomethingElse(myArray); <--- Works!!!!
DoSomethingElse([Obj1, Obj2, Obj3]); <--- Error E2001: Ordinal type required -> It is considering it like a set, not as an array
end;
What could be happening?
Thank you in advance.