gpt4 book ai didi

function - 我怎么知道PowerShell函数参数被省略了

转载 作者:行者123 更新时间:2023-12-02 22:13:44 25 4
gpt4 key购买 nike

考虑这样的函数:

function Test($foo, $bar)
{
...
}

我们可以称之为:

Test -foo $null
Test

如何知道何时省略了 -foo 以及何时为 $null?

最佳答案

如果您使用的是 Powershell V2 或更高版本,则可以使用 $PSBoundParameters 变量,该变量是一个字典,列出当前范围内的所有绑定(bind)参数。

参见this 讨论它的博客文章。

关于function - 我怎么知道PowerShell函数参数被省略了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/727912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com