Overview

Assoc Iteration

Iterating over associative arrays

Source Code

// Iterating over associative arrays
var colors: array [String] of String;
colors['Red'] := '#FF0000';
colors['Green'] := '#00FF00';
colors['Blue'] := '#0000FF';

// Iterating over keys
PrintLn('Keys:');
for var k in colors.Keys do
  PrintLn('  ' + k);

// Iterating over both
PrintLn('Entries:');
for var k in colors.Keys do
  PrintLn('  ' + k + ' => ' + colors[k]);

Result

Keys:
  Blue
  Green
  Red
Entries:
  Blue => #0000FF
  Green => #00FF00
  Red => #FF0000
On this page