繁体   English   中英

在一个匹配模式中匹配并绑定记录类型的字段?

[英]Match and bind the fields of record type in one match pattern?

是否可以在匹配模式语句中匹配并绑定记录类型的字段?

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) -> ....
match record with
| Some({A = a; B = b }) -> ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM