我从
编辑了一些Delphi 6代码if functionA then
else procedureB
到
if functionA then
if testC then procedureD
else procedureB
而不是正确的
if functionA then
begin
if testC then procedureD
end
else procedureB
如果编译器警告我连接的If -else没有相同的缩进,我就会在编译时意识到我的错误。请注意,正确的代码接受"else"分支,并仅在functionA不为真时调用procedureB。只有当functionA为真且testC为假时,错误的代码才接受else。
即使原来是
if not functionA then procedureB
我可能把它编辑错了版本。
是否有任何版本的Delphi警告不平衡的if-else缩进?
是否有任何版本的Delphi警告不平衡的if-else缩进?
。
这就是为什么在我的代码库中我从不使用单个语句而总是使用复合语句的原因。
if someBool then begin
DoStuff;
end else begin
DoOtherStuff;
end;