[fpc-pascal] Array as result in function.
Martin Schreiber
mse00000 at gmail.com
Fri Jan 20 07:52:27 CET 2017
On Thursday 19 January 2017 22:50:36 fredvs wrote:
> function array_in_out(arrayin: TArFloat): TArFloat;
> begin
> result := arrayin;
> end;
>
Do you change items of "arrayin" later? If so the items of the result array
will be changed too, dynamic array assignment copies the data pointer only.
http://www.freepascal.org/docs-html/current/ref/refsu15.html#x39-520003.3.1
Use
"
function array_in_out(arrayin: TArFloat): TArFloat;
begin
result:= copy(arrayin);
end;
"
if the result array must be independent.
Martin
More information about the fpc-pascal
mailing list