Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Join Two Arrays in ColdFusion

Is there a built-in way to join two arrays in ColdFusion, similar to JavaScript's array.concat()?

like image 801
Yisroel Avatar asked Jun 21 '10 02:06

Yisroel


People also ask

How do I combine two arrays?

To merge elements from one array to another, we must first iterate(loop) through all the array elements. In the loop, we will retrieve each element from an array and insert(using the array push() method) to another array. Now, we can call the merge() function and pass two arrays as the arguments for merging.

How do I combine two arrays into a new array?

The concat() method concatenates (joins) two or more arrays. The concat() method returns a new array, containing the joined arrays. The concat() method does not change the existing arrays.

Which method is used to combine elements of 2 arrays?

The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.

How do I combine two TypeScript arrays?

The Array. concat() is an inbuilt TypeScript function which is used to merge two or more arrays together.


Video Answer


1 Answers

Not really, but guess what, just use Java! :)

<cfset foo = [1,2,3]> <cfset bar = [4,5,6]> <cfset foo.addAll( bar )> 

reference: Java's Collection Interface API.

source: http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/merging-two-arrays-267

like image 191
Henry Avatar answered Sep 19 '22 18:09

Henry