不,equals 是一个赋值,因为这是常量的赋值方式。例如,考虑
const Pi = 3.1415;
或者
const s = 'This is an example';
还有“类型常量”:
const Pi: extended = 3.1415;
在上面的代码段中,我们定义了一个类型化的常量,它包含一个函数 signature function(const S: String): String
。我们为它分配(兼容的)功能SomeVariable1
。
SomVariable1
必须在代码的前面定义,例如,
function SomeVariable1(const S: String): String;
begin
result := S + '!';
end;
考虑以下示例:
function SomeVariable1(const S: String): String;
begin
result := S + '!';
end;
const
function1: function(const S: String): String = SomeVariable1;
procedure TForm1.FormCreate(Sender: TObject);
begin
caption := function1('test');
end;