How it works...
In this recipe, we did not initialize an array, because we already had two arrays as the input. When we created $CombinedList, PowerShell understood, from the assignment operation, that the resultant object type should be an array. When ListOne and ListTwo were added, PowerShell, instead of combining all the names into a single string, simply combined the two arrays and added each array as arrays themselves.
One important point to note here is that when an array is created, it is of a fixed length. In other words, suppose you said $ListOne += $ListTwo; the $ListOne array does not directly get altered, since the length of $ListOne is fixed at 10. PowerShell, in the background, measures the lengths of the two arrays in question, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access