3 ms·
I agree on those 2 points. regarding your second point, I don't like this unrolling either. The trick seems to be instead of : return $mylist Add a comm
by vmarsy 9y ago
I agree on those 2 points.
regarding your second point, I don't like this unrolling either.
The trick seems to be instead of :
return $mylist
Add a comma in front:
return ,$mylist
https://stackoverflow.com/a/16122464 https://stackoverflow.com/a/16122464
This will make sure [a] never gets changed to a, and [] never gets changed to $null
- kabdib 9y agoYow. That's a great answer . . . for some value of "I wish I didn't have to know that, but I do have to, so therefore it is great." :-)
- electricEmu 9y agoThere is a slight better trick. If you specify the variable as an array, it will always be treated as such. For example, instead of return $mylist ...you can... return @($mylist) The return keyword is unnecessary in PowerShell so this can be shortened to: @(mylist)