0

#PSTip Initializing multiple variables at once

Here’s another cool variables tip. Say you want to initialize a few variables to a specific value. Instead of doing:

$a = 1
$b = 1
$c = 1
$d = 1

Try PowerShell’s assignment expressions!

PS> $a=$b=$c=$d = 1
PS> $a,$b,$c,$d
1
1
1
1
Filed in: Columns, Tips and Tricks Tags: , , ,

Leave a Reply

Submit Comment

© 2014 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: