Powershell pitfalls

后端 未结 21 1451
梦谈多话
梦谈多话 2020-12-23 01:44

What Powershell pitfalls you have fall into? :-)

Mine are:

# -----------------------------------
function foo()
{
    @(\"text\")
}

# Expected 1, a         


        
21条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 02:32

    Here is something Ive stumble upon lately (PowerShell 2.0 CTP):

    $items = "item0", "item1", "item2"
    
    $part = ($items | select-string "item0")
    
    $items = ($items | where {$part -notcontains $_})
    

    what do you think that $items be at the end of the script?

    I was expecting "item1", "item2" but instead the value of $items is: "item0", "item1", "item2".

提交回复
热议问题