I need to pass a pair of value in array parameter function.
It is possible to call this form?
Call
Resul:= Validate( ['Johni', 18], ['Douglas', 22], ['Marangon', 19], [Dani, 29] )
Implementation
function Validate( /* Here, include pair array parameter */ ): Boolean
begin
// Implemetation
end;
The solution find.
TData = record
Name: string;
Age: Integer;
cosntructor Add( const AName: string; const AAge: Integer );
end;
cosntructor TData.Add( const AName: string; const AAge: Integer );
begin
Name:= AName
Age:= AAge;
end;
function Validate( const Array of TData ): Booelan;
begin
// implemtation
end;
Result:= Validate( [ TData.Add( 'Johni', 18 ), TData.Add('Douglas', 22), TData.Add('Marangon', 19) TData.Add(Dani, 29) ] );
Thank you.
TData.Addis the best that can be achieved. Though I would prefer the nameInitfor the method. If using an older version of Delphi that does not support record methods a simple:function InitTData(const AName: string; const AAge: Integer): TDataworks just as well.