Logo

Programming-Idioms

History of Idiom 7 > diff from v17 to v18

Edit summary for version 18 by :

Version 17

2015-08-21, 07:05:12

Version 18

2015-08-21, 07:10:32

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Imports
Classes, SysUtils
Code
var Iter:Integer;
    Items: array of TObject;
[...]
  for Iter := 0 to high(Items) do
    if assigned(Items[Iter]) then
      WriteLn(Format('Item %d = %s', [Iter, Items[Iter].ToString]));
Comments bubble
If you have an TObjects descendent, you can use the ToString Method to get it as a String.