3
我不明白爲什麼我看到這種行爲在PowerShell中:PowerShell的陷阱未觸發一貫
PS C:\> trap { "Got it!" } 1/0
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/0 <<<<
PS C:\> trap { "Got it!" } 1/$null
Got it!
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/$ <<<< null
爲什麼一個表達觸發陷阱和其他不?
有道理。爲了進一步支持你,這個: trap {「Got it!」 } invoke-expression「1/0」 給出了預期的行爲。 – zdan 2009-09-04 17:54:07