问题描述
我遇到了以下代码,无法理解双感叹号提供的操作.该代码片段来自CICD系统中使用的FAKE脚本. Microsoft的符号和运算符参考没有列出此运算符,也无法在 FAKE的API参考中找到.
I've come across the following code and can not understand what operation the double exclamation marks provide. This code-snipet is from a FAKE script used in a CICD system. 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")
推荐答案
!!
运算符采用文件模式,并返回与该模式匹配的文件的集合.
The !!
operator takes a file pattern and returns a collection of files matching the pattern.
例如,如果要打印当前文件夹中的所有文本文件,可以编写:
For example, if you want to print all text files in the current folder, you can write:
for file in !! "*.txt" do
printfn "%s" file
如果您查看源代码中的运算符定义,您可以看到它只是用于创建IGlobbingPattern
值的别名(请参见类型定义),其中包含由指定模式指定的文件. IGlobbingPattern
类型实现了IEnumerable
,因此您可以遍历文件,但是您可以使用IGlobbingPattern
进行其他操作,例如使用++
组合两个文件集或使用++
从文件集中删除某些文件. --
.
If you look at 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) that includes files given by the specified pattern. The IGlobbingPattern
type implements IEnumerable
, so you can iterate over the files, but you can do a couple of other things with IGlobbingPattern
such as combining two file sets using ++
or removing some files from a file set using --
.
这篇关于Fsharp/FAKE中的双感叹号(!!)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!