1

Issue

I am trying to reconstruct an array from the parts that constitute it but I am failing to obtain the same result. I instead end up with a single-dimension array with all the values from the respective arrays.

Question

How can I make sure that $brray is populated with the individual arrays and not only the values that they contain?

MWE

$array = @(("a1","a2"),("b1","b2"))

$a = @("a1","a2")
$b = @("b1","b2")

$brray = @()
$brray += $a
$brray += $b

function test(){
  Param(
    [string[]]
    $array
  )
  return $array
}

test($array)
test($brray)

Output

$array

a1 a2
b1 b2

$brray

a1
a2
b1
b2
Akaizoku
  • 456
  • 5
  • 19
  • 1
    Another good and short answer can be found here: https://stackoverflow.com/questions/6157179/append-an-array-to-an-array-of-arrays-in-powershell – Paxz Aug 20 '18 at 08:59

0 Answers0