简体   繁体   English

在F#中,float []和float list有什么区别?

[英]In F# what is the difference between float [] and float list?

The compiler is indicating "This expression was expected to have type float [] 编译器指示“此表达式应具有float []类型。
but here has type float list". I thought "[]" was the syntax for a list. I can't easily simplify the code for posting but perhaps someone can create an example that would generate this error. I searched several web pages on signatures. 但是这里的类型是float list“。我以为[[]]是列表的语法。我无法轻松简化发布代码,但也许有人可以创建一个示例来生成此错误。我在签名。

In type annotations, [] denotes an array. 在类型注释中, []表示数组。 This is despite the fact that in both patterns and expressions, it denotes lists. 尽管事实上在模式和表达式中它都表示列表。

When annotating lists, the syntax float list is usually preferred to the .NET standard notation List<float> , to avoid confusion with System.Collections.Generic.List<> (which has the ResizeArray type abbreviation in F#). 在注释列表时,语法float list通常比.NET标准注释List<float>更可取,以避免与System.Collections.Generic.List<> (在F#中具有ResizeArray类型缩写)混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM