Question
· Jan 15

Single Operation to Concatenate 2 %DynamicArrays?

Hello,

Is there a single ObjectScript operator or method to concatenate two %DynamicArrays?

I'm looking for something that will do the following:

set arr1 = [ 1, 2, 3 ]
set arr2 = [ 4, 5, 6 ]
set arrcombined = arr1.%Concatenate(arr2)

or 

set arrcombined arr1_arr2

With end result:

zw arrcombined
arr1=[1,2,3,4,5,6]  ; <DYNAMIC ARRAY>

I can iterate and %Pop over the 2nd array and %Push each popped entry to the 1st array, but I was looking for something more succinct.

Thanks in advance.

Product version: IRIS 2024.1
$ZV: IRIS for Windows (x86-64) 2024.1.1 (Build 347U) Thu Jul 18 2024 17:35:51 EDT
Discussion (4)1
Log in or sign up to continue

Thank you Dmitry; I confirmed it works when the dynamic arrays are stored in variables:

%SYS>w $zv
IRIS for Windows (x86-64) 2024.1.1 (Build 347U) Thu Jul 18 2024 17:35:51 EDT
%SYS>set arr1 = [1,2,3]
 
%SYS>set arr2 = [6,5,4]
 
%SYS>zw arr1.addAll(arr2)
[1,2,3,6,5,4]  ; <DYNAMIC ARRAY>
 
%SYS>do arr1.addAll(arr2)
 
%SYS>zw arr1
arr1=[1,2,3,6,5,4,6,5,4]  ; <DYNAMIC ARRAY>