【发布时间】:2015-12-12 02:44:54
【问题描述】:
如果我有下一个类型:
type Color(r: float, g: float, b:float) =
member this.r = r
member this.g = g
member this.b = b
static member ( * ) (c1:Color, c2:Color) =
Color (c1.r*c2.r, c1.g*c2.g, c1.b*c2.b)
static member Zero = Color(0.0,0.0,0.0)
我愿意:
let ca = Color(1.,1.,1.)
let cb = Color(1.,1.,1.)
ca = cb
我应该获得 true,但是通过脚本进行的 F# 交互却给了我 false 相反,如果我定义为:
let ca = Color(1.,1.,1.)
let cb = ca
ca = cb
它返回 true 尝试以这种方式比较定义类型的两个值,我做错了吗? 我怎样才能获得 true 作为结果?
谢谢
【问题讨论】:
标签: f# f#-interactive