What is The Loop Variable After a For Loop in Delphi?

Posted by Andreas Rejbrand on Stack Overflow See other posts from Stack Overflow or by Andreas Rejbrand
Published on 2010-04-09T21:01:48Z Indexed on 2010/04/10 0:23 UTC
Read the original article Hit count: 650

Filed under:
|
|

In Delphi, consider

var
  i: integer;

begin

  for i := 0 to N do
  begin
    { Code }
  end;

One might think that i = N after the for loop, but does the Delphi compiler guarantee this? Can one make the assumption that the loop variable is equal to its last value inside the loop, after a Delphi if loop?

Update

After trying a few simple loops, I suspect that i is actually equal to one plus the last value of i inside the loop after the loop... But can you rely on this?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about for-loop