[fpc-pascal] Array clearing
Benito van der Zander
benito at benibela.de
Thu Apr 13 11:50:26 CEST 2017
Hi Ryan,
> In the real world is anyone actually going to type that out every time? I’d bet most of us have an array class we use and ignore dynamic arrays all together because we all need basic operations like “add” and “remove”.
I, for one, have a huge list of array utility functions:
http://hg.benibela.de/bbutils/file/tip/bbutils.inc
I use arrays rather than classes, because latter are not reference counted
Bye,
BeniBela
On 04/12/2017 04:30 PM, Ryan Joseph wrote:
>> On Apr 12, 2017, at 9:24 PM, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
>>
>> SetLength(Array,Length(Array)+1);
>>
>> You will get an additional element (filled with zeros).
>> Then you can set
>>
>> Array[High(Array)] := whateveryouwant;
> Well sure, but this kind of code is exactly what programmers abstract and reuse so it’s a perfect candidate for a function.
>
> SetLength(Array,Length(Array)+1);
> Array[High(Array)] := …
>
> In the real world is anyone actually going to type that out every time? I’d bet most of us have an array class we use and ignore dynamic arrays all together because we all need basic operations like “add” and “remove”.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170413/ad5ff141/attachment.html>
More information about the fpc-pascal
mailing list