How to implement foreachable template Array class: class Array(T) { T[] arr; public this() {} public int count() { return arr.length; } public void add(T t) { arr.length = arr.length+1; arr[length-1] = t; } opApply() { ??? } } I could not find out how to write correct operator opApply.