[Pas2js] Testing generics

warleyalex warleyalex at yahoo.com.br
Sat Oct 19 19:56:35 CEST 2019


{$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)
  );




--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list