Bruce Payette blogs the following...
Link to Windows PowerShell : PowerShell Tip: How to “shift” arrays…
I haven't paid much attention to "mulitple assignment" in PoSH but this is a great example of what it can buy for us. In the past in other languages we could initialize variables easily:
a, b, c,d = 0
name, rank, serial = "empty"
etc...
In PoSH:
$a,$b,$c,$d=0,1,2,3
$name,$rank,$serial = "empty","hello","world"
$a="empty","hello","world"
then
$x,$y,$z=$a # will distribute the values back into individual variables
$m,$n=$a will put the first element in to $m and the remainder in $n
Read Bruce's blog to see how this plays out with arrays. It's quite useful and very cool.
No comments:
Post a Comment