Hacker News new | ask | show | jobs
by vmarsy 3205 days 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

This will make sure [a] never gets changed to a, and [] never gets changed to $null

2 comments

There 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)
Yow. 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." :-)