Simple question, why "Multiply" operator works, and "Equal" does not. compiler give error "[dcc32 Error] Project1.dpr(33): E2015 Operator not applicable to this operand type"
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
TMyRecord2 = record
public
class operator Equal(const a: TMyRecord2; const b: array of Integer): boolean;
class operator Multiply(const a: TMyRecord2; const b: array of Integer): TMyRecord2;
end;
class operator TMyRecord2.Equal(const a: TMyRecord2; const b: array of Integer): boolean;
begin
Result := True;
end;
class operator TMyRecord2.Multiply(const a: TMyRecord2; const b: array of Integer): TMyRecord2;
begin
Result := a;
end;
var
b: boolean;
r: TMyRecord2;
begin
try
r := r * [10]; // this line is compiled
b := r = [10]; // this line is not compiled
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.