是否可以在匹配模式语句中匹配和绑定记录类型的字段?
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) -> ....
答案 0 :(得分:4)
match record with
| Some({A = a; B = b }) -> ...