I have a TDictionary that stores a bunch of objects indexed by name, and I would like to be able to examine all the objects. So I tried this:
var enumerator: TMyObject; begin for enumerator in myDictionary do
But this did not compile. "Incompatible types:" TMyObject "and" TPair "
So, I tried it a little differently:
var enumerator: TPair<string, TMyObject>;
This also did not compile. This error message is even stranger: Incompatible types: "TPair" and "TPair"
So, apparently, I need some kind of funky grammar to list my vocabulary with a loop for ... c . Does anyone know how to declare it correctly?
EDIT: Fabio Gomez gave an example that works correctly, but my code still does not compile using its method. Maybe because I work in another unit? The dictionary and class that it uses for the Value side are defined in one block, and this code in another place. Does this make it a compiler error? Can anyone confirm this?
EDIT 2: Found a problem. http://qc.embarcadero.com/wc/qcmain.aspx?d=69461 if anyone is interested.
source share