As a newbie I’m probably missing something here, but doesn’t the “for each” construct do this? From the wiki:
For Each
’For each’ can be used to iterate over anything that implements the IEnumerable interface. ‘For each’ uses this syntax:
for each el: String in mylist do
for each matching el: String in mylist do
for each el in mylist do
for el in mylist do
In the first two cases the variable is typed, if it’s not typed the type is inferred from the IEnumerable (it will fail if it can’t). The matching keyword will only execute the loop for values that really are of that type, so it will skip any non-strings. In the last case the ‘each’ keyword is left out, which is optional. The ‘for each’ is skipped completely if the value after in is nil.
Does this differ from what the OP is asking for?