1
是否有可能在匹配模式語句中匹配和綁定記錄類型的字段?在一個匹配模式中匹配和綁定記錄類型的字段?
type R = { A:int; B:string }
type R' = R option
let record: R' = .....
match record with
| Some(r) ->
let a, b = r.A, r.B // Can this row be merged to the match pattern like the tuple example below?
....
| None -> ....
預計類似的元組下面
match record with
| Some(a, b) -> ....
值得一提的是,在匹配模式能分到這是與許多領域的記錄是有用的,像記錄的不是所有的字段'有些({B = b}) - > //在這裏使用b ... – Petr 2014-11-04 00:02:40