[Pas2js] Testing generics
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Oct 21 13:11:58 CEST 2019
On Sat, 19 Oct 2019 10:56:35 -0700 (MST)
warleyalex via Pas2js <pas2js at lists.freepascal.org> wrote:
> {$mode delphi}
> {$modeswitch AdvancedRecords}
>
> type
> TCustomer = record
> private
> FName: string;
> FMoney: Currency;
> public
> constructor Create(const Name: string; Money: Currency);
> property Name: string read FName write FName;
> property Money: Currency read FMoney write FMoney;
> function ToString: string;
> end;
>
> { TCustomer }
>
> constructor TCustomer.Create(const Name: string; Money: Currency);
> begin
> FName := Name;
> FMoney := Money;
> end;
>
> function TCustomer.ToString: string;
> begin
> Result := Format('Name: %s >>> Money: %m', [Name, Money]);
> end;
>
> (...) Hum, it's not possible yet to compile this piece of code:
> var
> CustomersArray: TArray<TCustomer>;
>
> begin
> CustomersArray := TArray<TCustomer>.Create(
> TCustomer.Create('AAA', 10),
> TCustomer.Create('BBB', 20),
> TCustomer.Create('CCC', 30),
> TCustomer.Create('DDD', 40)
> );
I get:
Error: illegal qualifier "." after "array of TCustomer"
Do you have a type helper for TArray<TCustomer>?
Mattias
More information about the Pas2js
mailing list