Why does PowerShell flatten arrays automatically?

前端 未结 3 1687
遇见更好的自我
遇见更好的自我 2021-01-18 13:32

I\'ve written some pwsh code

\"a:b;c:d;e:f\".Split(\";\") | ForEach-Object { $_.Split(\":\") }
# => @(a, b, c, d,          


        
3条回答
  •  情歌与酒
    2021-01-18 14:15

    With foreach-object, it's usually useful to unwrap the array:

    ps | foreach modules | sort -u modulename
    

提交回复
热议问题