James Richters via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am Di., 8. Sep. 2020, 20:07:
> What’s the difference between TList and TFPGList? Which one is better > for this example? > The main difference is that TFPGList ist a generic, thus when you specialize it with your record you'll have a typesafe object where you don't need to manually work with pointers while for TList you either need to work with pointers or declare a descendant with typesafe setters/getters like you had done in the other mail. You could also take a look at the generic TList in Generics.Collections which does not require an = operator like TFPGList does. Please note that if you work with TFPGList or the Generics.Collection.TList then you need to modify an entry using a local variable if your entries are records: entry := mylist[i]; entry.field := entry.field * 2; mylist[i] := entry; This is because the getter for the Items property will provide a /copy/ of the entry. With Classes.TList you'd use a pointer however and thus you can modify it in place. Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal