Don’t do that #1: Multiple lines to initialize variables

By | February 24, 2015

Don’t do that: The following code requires multiple lines to initialize variables to 0.

$result = 0
$count = 0
$found = 0
$current = 0
$skip = 0


Do that: It’s possible to initialize multiple variables in one line:
$result = $count = $found = $current = $skip = 0

Note: It’s also possible to assign different values to different variables in one line :
$a, $b = 1, 2


next-button

One thought on “Don’t do that #1: Multiple lines to initialize variables

  1. Pingback: Don't do that #2 : Multiple lines to read variables - Powershell Guru

Leave a Reply

Your email address will not be published. Required fields are marked *