解释F#中的'符号 [英] Explain the ' notation in F#

查看:93
本文介绍了解释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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆