3 ms·
Look up strict mode. Array unrolling is a legitimate gripe. The design justification is that Powershell is pipeline-oriented. On occasions where you specifical
by psd1 4y ago
Look up strict mode.
Array unrolling is a legitimate gripe. The design justification is that Powershell is pipeline-oriented. On occasions where you specifically need an array, either type your variable or use the array operator:
[object[]]$foo = 42
$foo = @(42)
- ggorlen 4y agoGood point about strict mode. However, I've collected a few gotchas[1] that I don't think strict mode helps with (as seems to be the case with languages that offer strict mode, it's not enough). If you're curious and have time to take a look and let me know what I might have misunderstood, I'd appreciate it. I think I'm missing which problem your code solves. There are a few array issues in my gotcha journal. Adding types like [object[][]] doesn't seem to help with getting PS to understand nested arrays with 1 element, for example, and $foo = @(42) is the array declaration syntax I usually use. [1]: https://gist.github.com/ggorlen/1e337f211f508124321c8bc7c1d264ed https://gist.github.com/ggorlen/1e337f211f508124321c8bc7c1d2...