1
我想檢查一個變量是某種類型的,像這樣:F#爲什麼我不能使用:? F#交互式操作符?
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是一個布爾。
這是因爲你正在嘗試密封類型。 – Gustavo