for in Array | step



for in Array | step
Smart pascal source code
const primaries: array [3 .. 6] of Integer = [3, 5, 7, 9]; const colors: array [0 .. 2] of String = ['red', 'green', 'blue']; type TMyClass = class Field: String; constructor Create(f: String); begin Field := f; end; procedure DoWriteLn; begin WriteLn(Field); end; end; {---- main.pas ----} var i: Integer; c: String; objs: array of TMyClass; Begin objs.Add(new TMyClass('hello')); objs.Add(TMyClass.Create('world')); for i in primaries do WriteLn(i); for c in colors do WriteLn(c); var o: TMyClass; for o in objs do o.DoWriteLn; for i in primaries step 2 do WriteLn(i); { <<< CONSOLE OUTPUTS >>> 3 5 7 9 red green blue hello world 3 7 }