How can I pass array of string a parameter to function in delphi
13:49 21 Dec 2017

I have a problem with Delphi.

I wrote a function like this:

function MyFunction(arr: array of AnsiString): Boolean;
begin
  //code here
end;

And now, when I pass an array of AnsiString directly into function, like this, everything works perfectly:

MyFunction(['one', 'two', 'three']);

But, when I try to store this array like this:

var arr: array of AnsiString;

procedure MyProcedure;
begin
  arr[0] := ['one', 'two', 'three'];
  MyFunction(arr[0]);
end;

There is a mismatch error.

I'm a beginner with Delphi, but this is really confusing.

arrays delphi delphi-10.1-berlin