Collection c; foreach (T value; c) { ... statements ... } foreach (U key, T value; c) { ... statements ... } class Collection { ... int opApply(int delegate(T)) { ... } }