解释F#中的'符号 [英] Explain the ' notation in F#
问题描述
我正在学习F#,当我在Visual Studio中键入任何代码并在 F#Interactive 上运行它们时,会显示类似
的内容val foo : x:'a -> 'a
我想这意味着foo
是一个接收类型为参数的参数x
并返回与x类型相同的值的函数.
但是 '
是什么意思??许多功能也在intellisense上显示了这种情况.
单引号('
)表示该参数的类型是通用的.可以像您提供的示例一样进行推断,也可以显式地应用它.
有关详细信息,请参见此处.
I'm learning F#, when I type any code in Visual Studio and run them on F# Interactive it shows me things like
val foo : x:'a -> 'a
I imagine this mean that foo
is a function that receive a paramater x
of a type, and returns a value of same x's type.
But What does that '
mean? Many functions show such thing on intellisense too.
The single quote mark ('
) means that the type of that parameter is generic. It can be inferred, like the example you gave, or it can be explicitly applied.
See here under Implicitly Generic Constructs for more information.
这篇关于解释F#中的'符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!