相关疑难解决方法(0)

Powershell陷阱

您遇到的Powershell陷阱是什么?:-)

我的是:

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

# Expected 1, actually 4.
(foo).length

# -----------------------------------
if(@($null, $null))
{
    Write-Host "Expected to be here, and I am here."
}

if(@($null))
{
    Write-Host "Expected to be here, BUT NEVER EVER."
}

# -----------------------------------

function foo($a)
{
    # I thought this is right.
    #if($a -eq $null)
    #{
    #    throw "You can't pass $null as argument."
    #}

    # But actually it should be:
    if($null -eq $a)
    {
        throw "You can't pass $null …
Run Code Online (Sandbox Code Playgroud)

powershell

24
推荐指数
6
解决办法
4654
查看次数

标签 统计

powershell ×1