在Delphi prism中,我们可以声明仅在特殊场合需要的变量.
例如:在棱镜中
If acondition then
begin
var a :Integer;
end;
a := 3; //this line will produce error. because a will be created only when the condition is true
Run Code Online (Sandbox Code Playgroud)
这里'a'不能与3分配,因为它嵌套在分支内.我们如何声明一个只能在delphi win32中的分支内部使用的变量.所以我可以减少内存使用量,因为它只在某个条件成立时才会被创建;
如果减少内存使用不是问题我们有什么缺点(或者我们没有)
delphi ×1