Reputation: 233
Is it possible to use an open array as index type for indexed properties?
unit OpenArrayAsPropertyIndex;
interface
type
TFoo = class
private
function getBar(Index: array of Integer): String;
public
// [DCC Error]: E2008 Incompatible types
property Bar[Index: array of Integer]: String read getBar;
end;
implementation
function TFoo.getBar(Index: array of Integer): String;
begin
end;
end.
The property getter is generated by pressing Ctl+Shift+C in the IDE, but this code doesn't compile and gives error "E2008 Incompatible types". So, is it a language limitation, or what is the correct parameter signature for the getter?
Upvotes: 1
Views: 178
Reputation: 47714
Instead of array of Integer
use TIntegerDynArray
from System.Types or a similar self declared type.
type
TIntArray = array of Integer;
TFoo = class
private
function getBar(Index: TIntArray): String;
public
property Bar[Index: TIntArray]: String read getBar;
end;
function TFoo.getBar(Index: TIntArray): String;
begin
end;
Upvotes: 1