【发布时间】:2016-09-12 14:07:34
【问题描述】:
我正在尝试检查变量是否属于某种类型,如下所示:
let s = "abc"
let isString = s :? string
但在 F# 交互中,我收到以下错误:
error FS0016: The type 'string' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion.
为什么会这样?我希望 isString 是一个布尔值。
【问题讨论】:
-
那是因为您正在尝试使用密封类型。
标签: f# typechecking f#-interactive