Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Obj-c
@import Foundation;
[items enumerateObjectsUsingBlock:^(id x, NSUInteger i, BOOL *stop) {
  NSLog(@"Item %lu = %@",(u_long)i,x);
}];

The plain-C approach can be used as well. Showing another, object-oriented possibility. Typecast needed with %lu (same as in printf) for multi-platform compatibility. The stop argument serves same purpose as plain-C break
with Ada.Text_IO;
use Ada.Text_IO;
for I in Items'Range loop
   X := Items (I);
   Put_Line (Integer'Image (I) & " " & Integer'Image (X));
end loop;

Assuming Items is an array of integers.

New implementation...