delphi - Delphi的任何版本都警告if-else缩进不平衡吗?

标签 delphi if-statement compiler-warnings

我从中编辑了一些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缩进不一样,那么我会在编译时意识到我的错误。请注意,只有在functionA不是true的情况下,正确的代码才会使用“ else”分支并调用procedureB。仅当functionA为true且testC为false时,错误的代码才会使用“ else”。

即使原来是

if not functionA then procedureB


我可能已将其编辑为错误的版本。

Delphi的任何版本都警告if-else缩进不平衡吗?

最佳答案

Delphi的任何版本都警告if-else缩进不平衡吗?


没有。

这就是为什么在我的代码库中我从不使用单个语句,而始终使用复合语句的原因。

if someBool then begin
  DoStuff;
end else begin
  DoOtherStuff;
end;

关于delphi - Delphi的任何版本都警告if-else缩进不平衡吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894689/

相关文章:

c - 对 32 位地址空间使用 64 位整数迭代器?

java - 为什么显式 boolean 测试会出现死代码警告,而隐式 boolean 测试不会出现死代码警告

windows - 为什么自定义光标图像显示不正确?

delphi - 如何在 pascal 中不使用 for 循环同时设置多个数组字段?

linux - Ksh 和 if 语句

c# - 如何让控制台读取所有条件

c# - 大括号触发编译器警告错误C#

delphi - 使用WinAPI在Delphi中模拟键盘输入

delphi - 需要将唯一的整数值与类相关联

c++ - !(variable) 和 (!variable) 之间的区别