Fsharp / FAKE 中的双感叹号 (!!) 是什么意思?

What does a double exclamation mark (!!) in Fsharp / FAKE?

我看到了下面的代码,无法理解双感叹号提供的操作。此代码片段来自 CICD 系统中使用的 FAKE 脚本。 Microsoft's Symbol and Operator Reference does not list this operator, nor can I find it in FAKE's API Reference.

  !! (projectPackagePath + "/*.zip")
    |> Seq.iter(fun path ->
      trace ("Removing " + path)
      ShellExec tfCommand ("delete " + path + " /noprompt")

另一个用法示例

let buildLabelFiles = 
    !!(labelPath @@ "*.txt")

!! 运算符采用文件模式和 returns 匹配该模式的文件集合。

比如要打印当前文件夹下的所有文本文件,可以这样写:

for file in !! "*.txt" do
  printfn "%s" file

如果您查看 the operator definition in the source code, you can see that it is just an alias for creating a IGlobbingPattern value (see the type definition),其中包含指定模式给出的文件。 IGlobbingPattern 类型实现了 IEnumerable,因此您可以遍历文件,但您可以使用 IGlobbingPattern 做一些其他事情,例如使用 ++ 组合两个文件集或使用 --.

从文件集中删除一些文件