在PowerShell中整平数组 [英] Flatten array in PowerShell
本文介绍了在PowerShell中整平数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我们有
$ a = @(1,@(2,@(3)))
我想要平展$ a以获得@(1,2,3)
我找到了 a解决方案
@($ a |%{$ _})count
$ c 解决方案 / div> 管道是平铺嵌套结构的正确方法,因此我不确定更多优雅。是的,语法是一个位线嘈杂的外观,但坦率地相当服务。
Assume we have
$a = @(1, @(2, @(3)))
I whould like to flatten $a to get @(1, 2, 3)
I have found a solution
@($a | % {$_}).count
But may be there is a more elegant way?
解决方案 Piping is the correct way to flatten nested structures, so I'm not sure what would be more "elegant". Yes, the syntax is a bit line-noisy looking, but frankly quite serviceable.
这篇关于在PowerShell中整平数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文