1
我有學校類(2層構造)識別聯合:與已定義的類
type School(name, antiquity) =
member this.Name: string = name
member this.Antiquity: int = antiquity
new(name) = School(name, 0)
而各類建築:
type Building =
| House
| School of School
而且我想知道是什麼類型的建築物與功能「知道類型」:
let knowType building =
match building with
| House -> "A house!"
| School -> "A school" // Error
「knowType」中的錯誤是在第二種情況下:「該構造函數被應用0參數,但期望1「。