12.8.5 Dynamic array operators

There is only one dynamic array operator: +. This operator is available in Delphi mode, but must be enabled explicily using the modeswitch arrayoperators in objfpc mode:

{$mode objfpc}  
{$modeswitch arrayoperators}

When enabled, its action is similar to the concation for strings: to concatenate the contents of the two arrays it acts on. The array element type must of course be identical for both arrays, i.e. the following will work:

{$mode objfpc}  
{$modeswitch arrayoperators}  
var  
  a,b, c : array of byte;  
 
begin  
  a:=[0,1,2];  
  b:=[3,4,5];  
  c:=a+b;  
  writeln('C has ',length(c),' elements');

But the following will not work:

{$mode objfpc}  
{$modeswitch arrayoperators}  
 
var  
  b, c : array of byte;  
  a : array of integer;  
 
begin  
  a:=[0,1,2];  
  b:=[3,4,5];  
  c:=a+b;  
  writeln('C has ',length(c),' elements');

The compiler will give an error when compiling this code.