我无法找到一个例子。如何为powershell函数制作原型?
function exampleFunc();
//other stuff that calls the example function
Function exampleFunc(){//stuff}
答案 0 :(得分:3)
PowerShell不支持原型函数,转发声明或您想要使用的任何术语。在PowerShell中,当您使用function
关键字时,您需要定义一个函数。如果使用相同的函数名称调用它两次,则更改函数的定义。
This question关于bash的同一问题列出了解决问题的常用方法。你可以在PowerShell中做同样的事情。
另一个选择是使用Begin {} Process {} End {}
高级函数构造,并将所有函数声明放在Begin {}
部分。
答案 1 :(得分:0)
您可以通过右键单击或通过快捷按钮Ctrl + J访问Powershell ISE(集成编码环境)中的代码段。
答案 2 :(得分:0)
以下是@ bacon-bits代码的样子
var x = 100;
function f() {
var x;
console.log(x); // prints undefined as expected
}
f();