【发布时间】:2011-08-30 00:36:05
【问题描述】:
在处理文本文件时可以在 While 循环中使用 Continue 吗?
我想做一些处理并检查一些值。如果为真,我想跳过一次迭代。如果为 false,我想继续下一组行(继续处理)。
while not EOF(InFile) do
begin
DoSomething;
if (AcctTag = '') OR (MasterId = '') then
Continue;
DoSomething;
end;
这种情况下的 continue 会跳过迭代吗?
【问题讨论】:
-
我有时会发现如果您可以跳过继续,它会使代码更清晰。在您的情况下: If (AcctTag '') And (MasterId '') Then DoSomething;
-
@johnny,完全同意,continue 就像一个 goto,使用它时要格外小心,否则就要面对意大利面条代码怪物的愤怒。
-
if (AcctTag = '') OR (MasterId = '') then Next;