[fpc-devel] Array assignment operator

Sven Barth pascaldragon at googlemail.com
Sun Nov 4 17:24:31 CET 2018


Am So., 4. Nov. 2018, 12:23 hat Schindler Karl-Michael <
karl-michael.schindler at web.de> geschrieben:

>
>
> > Am 04.11.2018 um 12:00 schrieb Ben Grasset <operator97 at gmail.com>:
> >
> > From: Ben Grasset <operator97 at gmail.com>
> > To: FPC-Devel users discussions <fpc-devel at lists.freepascal.org>
> > Subject: Re: Array assignment operator
> > Message-ID: <
> CAL4d7FjPfX-ysT6Z3--fhPR9Pts-N47ksFN6m2pHD7SunzwpJg at mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > On Sat, Nov 3, 2018 at 4:44 PM Gennady Agranov <gennadyagranov at gmail.com
> >
> > wrote:
> >
> >> Hi,
> >>
> >> Leaving aside the reason why the MiSchi's solution doesn't work the main
> >> question is still not answered :)
> >>
> >> If you have integer dynamic array "MyArray" is there a way for the
> >> following statement to compile and work correctly:
> >>
> >> MyArray := 5;
> >>
> >
> > Uh, yes? That's what my example showed.
>
> In your example the length of the array was set to the number and the
> elements of the array assigned to their index, whereas my intention is to
> keep the length of the array and fill all elements to the same number.
>

The operator always creates a new array and does not modify the existing
one.
You'd need to abuse a binary operator (e.g. >< or even <=) for this.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181104/115b0c89/attachment.html>


More information about the fpc-devel mailing list