I'm currently having an issue with a script that builds an array based off of a dynamic set of servers\priorities that are passed to it. For example, based off of the input below
server1,200
server2,200
I want to build something that looks like
$arr=@() #at this point I have an empty array
$arr+=@("server1",200) #at this point, I would expect to have an array
#that itself holds another array
However at this point, when I run the this I get unexpected output
echo $arr.count # result is 2, rather than the 1 I would expect
# It appears to be treating $arr as a single array
# with two members (server1 and 200) rather than an array
# that holds an array, which itself has two members
However, if I add another empty array to my array:
$arr = @()
$arr += @()
$arr += $("server1",200)
$arr.count # output is 2, which is the desired result
I get my desired result. My question is.. can I get my desired result of a jagged\multidimensional array with just a single array inside of it? This isn't going to be a common scenario as a majority of the time there will be multiple sets of items that I'm dealing with, however I'd like to account for all scenarios and this may be one that pops up. I'd just like to not have to add an additional step of filtering out an empty array just to satisfy this.
Any input would be greatly appreciated.