Filling variables from arrays

It is possible to fill two (or more) variables from an array:

$i, $j = 1, 2 

This is often encountered when splitting a string:

$firstName, $lastName = "First Last" -split " " 
$firstName, $lastName = "First Last".Split(" ") 

If the array is longer than the number of variables, all remaining elements are assigned to the last variable. For example, the k variable will hold 3, 4, and 5, as can be seen as follows:

$i, $j, $k = 1, 2, 3, 4, 5 

If there are too few elements, the remaining variables will not be assigned a value. In this example, k will be null:

$i, $j, $k = 1, 2 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.28.50