我遇到了以下代码,无法理解双感叹号提供的操作.此代码snipet来自CICD系统中使用的FAKE脚本.Microsoft的符号和运算符参考不会列出此运算符,也无法在FAKE的API参考中找到它.
!! (projectPackagePath + "/*.zip")
|> Seq.iter(fun path ->
trace ("Removing " + path)
ShellExec tfCommand ("delete " + path + " /noprompt")
Run Code Online (Sandbox Code Playgroud)
另一个使用示例
let buildLabelFiles =
!!(labelPath @@ "*.txt")
Run Code Online (Sandbox Code Playgroud)
Tom*_*cek 10
该!!操作需要一个文件模式,并返回与模式匹配的文件的集合.
例如,如果要打印当前文件夹中的所有文本文件,可以编写:
for file in !! "*.txt" do
printfn "%s" file
Run Code Online (Sandbox Code Playgroud)
如果查看源代码中的运算符定义,可以看到它只是一个别名,用于创建包含指定模式给定文件的IGlobbingPattern值(请参阅类型定义).该IGlobbingPattern式工具IEnumerable,这样你就可以遍历文件,但你可以做一些其他事情IGlobbingPattern,如使用组合两个文件集++,或使用从文件集中删除一些文件--.