[fpc-pascal] Array clearing

Ryan Joseph genericptr at gmail.com
Wed Apr 12 16:30:43 CEST 2017

> 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. 

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”.

More information about the fpc-pascal mailing list