相关疑难解决方法(0)

Powershell"私人"范围似乎毫无用处

我从下面得到了以下脚本:

$private:a = 1
Function test  {
    "variable a contains $a"
    $a = 2
    "variable a contains $a"
}
test
Run Code Online (Sandbox Code Playgroud)

打印2.没问题.如果我删除"私人",如下所示:

$a = 1
Function test  {
    "variable a contains $a"
    $a = 2
    "variable a contains $a"
}
Run Code Online (Sandbox Code Playgroud)

仍然打印"2".似乎没有区别.您能否快速提供"私人"范围如何影响结果的样本?

谢谢.

powershell scope private

6
推荐指数
2
解决办法
3473
查看次数

标签 统计

powershell ×1

private ×1

scope ×1