您遇到的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 ×1