F# 支持类不错,但提供了另一种解决方案,称为对象表达式(object expressions)。这是受函数编程启发,往往是更优雅,因为,创建有用的值之前,我们不必要写任何类的声明。
基于52个网页-相关网页
The following example illustrates several different types of object expressions.
下面的示例阐释了几种不同类型的对象表达式。
You use object expressions when you want to avoid the extra code and overhead that is required to create a new, named type.
若要避免创建新的命名类型所需的额外代码和开销,可以使用对象表达式。
Object expressions, which enable you to define small objects implicitly in expressions as needed, instead of declaring a new type and instantiating an object.
物件运算式,可让您在需要时于运算式中隐含定义小型物件,而不用宣告新型别以及具现化物件。
应用推荐