For example, when using a for..in loop to iterate through a TIdStackLocalAddressList from TIdStack.GetLocalAddressList(), the loop variable is of type TCollectionItem instead of TIdStackLocalAddress, thus requiring a typecast to access members of TIdStackLocalAddress:
var List: TIdStackLocalAddressList;
GStack.GetLocalAddressList(List);
for var item in List do
begin
item.IPAddress; // error
TIdStackLocalAddress(item).IPAddress; // ok
end;
This is because the loop enumerator is implemented by the base TCollection class. TIdStackLocalAddressList would need to implement its own enumerator in order to expose access to its TIdStackLocalAddress elements.
The same issue exists for other TCollection-derived classes in Indy.
For example, when using a
for..inloop to iterate through aTIdStackLocalAddressListfromTIdStack.GetLocalAddressList(), the loop variable is of typeTCollectionIteminstead ofTIdStackLocalAddress, thus requiring a typecast to access members ofTIdStackLocalAddress:This is because the loop enumerator is implemented by the base
TCollectionclass.TIdStackLocalAddressListwould need to implement its own enumerator in order to expose access to itsTIdStackLocalAddresselements.The same issue exists for other
TCollection-derived classes in Indy.